2 * Scroll windows and DCs
4 * Copyright David W. Metcalfe, 1993
8 static char Copyright
[] = "Copyright David W. Metcalfe, 1993";
15 /* #define DEBUG_SCROLL */
22 /*************************************************************************
23 * ScrollWindow (USER.61)
26 void ScrollWindow(HWND hwnd
, short dx
, short dy
, LPRECT rect
, LPRECT clipRect
)
32 dprintf_scroll(stddeb
,"ScrollWindow: dx=%d, dy=%d, rect=%d,%d,%d,%d\n",
33 dx
, dy
, rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
38 GetClientRect(hwnd
, &rc
);
42 GetClientRect(hwnd
, &cliprc
);
44 CopyRect(&cliprc
, clipRect
);
46 hrgnUpdate
= CreateRectRgn(0, 0, 0, 0);
47 ScrollDC(hdc
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, NULL
);
48 InvalidateRgn(hwnd
, hrgnUpdate
, TRUE
);
53 /*************************************************************************
57 BOOL
ScrollDC(HDC hdc
, short dx
, short dy
, LPRECT rc
, LPRECT cliprc
,
58 HRGN hrgnUpdate
, LPRECT rcUpdate
)
60 HRGN hrgnClip
, hrgn1
, hrgn2
;
63 DC
*dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
);
65 dprintf_scroll(stddeb
, "ScrollDC: dx=%d, dy=%d, rc=%d,%d,%d,%d\n", dx
, dy
,
66 rc
->left
, rc
->top
, rc
->right
, rc
->bottom
);
73 hrgnClip
= CreateRectRgnIndirect(cliprc
);
74 SelectClipRgn(hdc
, hrgnClip
);
79 src
.x
= XDPTOLP(dc
, rc
->left
);
80 dest
.x
= XDPTOLP(dc
, rc
->left
+ abs(dx
));
84 src
.x
= XDPTOLP(dc
, rc
->left
+ abs(dx
));
85 dest
.x
= XDPTOLP(dc
, rc
->left
);
89 src
.y
= YDPTOLP(dc
, rc
->top
);
90 dest
.y
= YDPTOLP(dc
, rc
->top
+ abs(dy
));
94 src
.y
= YDPTOLP(dc
, rc
->top
+ abs(dy
));
95 dest
.y
= YDPTOLP(dc
, rc
->top
);
98 width
= rc
->right
- rc
->left
- abs(dx
);
99 height
= rc
->bottom
- rc
->top
- abs(dy
);
101 if (!BitBlt(hdc
, dest
.x
, dest
.y
, width
, height
, hdc
, src
.x
, src
.y
,
108 hrgn1
= CreateRectRgn(rc
->left
, rc
->top
, rc
->left
+dx
, rc
->bottom
);
110 hrgn1
= CreateRectRgn(rc
->right
+dx
, rc
->top
, rc
->right
,
113 hrgn1
= CreateRectRgn(0, 0, 0, 0);
116 hrgn2
= CreateRectRgn(rc
->left
, rc
->top
, rc
->right
, rc
->top
+dy
);
118 hrgn2
= CreateRectRgn(rc
->left
, rc
->bottom
+dy
, rc
->right
,
121 hrgn2
= CreateRectRgn(0, 0, 0, 0);
123 RgnType
= CombineRgn(hrgnUpdate
, hrgn1
, hrgn2
, RGN_OR
);
126 if (rcUpdate
) GetRgnBox( hrgnUpdate
, rcUpdate
);
131 /*************************************************************************
132 * ScrollWindowEx (USER.319)
135 int ScrollWindowEx(HWND hwnd
, short dx
, short dy
, LPRECT rect
, LPRECT clipRect
,
136 HRGN hrgnUpdate
, LPRECT rcUpdate
, WORD flags
)
141 dprintf_scroll(stddeb
,"ScrollWindowEx: dx=%d, dy=%d, rect=%d,%d,%d,%d\n",
142 dx
, dy
, rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
147 GetClientRect(hwnd
, &rc
);
150 if (clipRect
== NULL
)
151 GetClientRect(hwnd
, &cliprc
);
153 CopyRect(&cliprc
, clipRect
);
155 ScrollDC(hdc
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
157 if (flags
| SW_INVALIDATE
)
159 RedrawWindow(hwnd
, NULL
, hrgnUpdate
,
160 RDW_INVALIDATE
| ((flags
& SW_ERASE
) ? RDW_ERASENOW
: 0));
163 ReleaseDC(hwnd
, hdc
);