2 * Scroll windows and DCs
4 * Copyright David W. Metcalfe, 1993
13 /* #define DEBUG_SCROLL */
20 /*************************************************************************
21 * ScrollWindow (USER.61)
24 void ScrollWindow(HWND hwnd
, short dx
, short dy
, LPRECT rect
, LPRECT clipRect
)
30 dprintf_scroll(stddeb
,"ScrollWindow: dx=%d, dy=%d, rect=%ld,%ld,%ld,%ld\n",
31 dx
, dy
, (LONG
)rect
->left
, (LONG
)rect
->top
, (LONG
)rect
->right
, (LONG
)rect
->bottom
);
36 GetClientRect(hwnd
, &rc
);
40 GetClientRect(hwnd
, &cliprc
);
42 CopyRect(&cliprc
, clipRect
);
44 hrgnUpdate
= CreateRectRgn(0, 0, 0, 0);
45 ScrollDC(hdc
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, NULL
);
46 InvalidateRgn(hwnd
, hrgnUpdate
, TRUE
);
51 /*************************************************************************
55 BOOL
ScrollDC(HDC hdc
, short dx
, short dy
, LPRECT rc
, LPRECT cliprc
,
56 HRGN hrgnUpdate
, LPRECT rcUpdate
)
58 HRGN hrgnClip
, hrgn1
, hrgn2
;
61 DC
*dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
);
63 dprintf_scroll(stddeb
, "ScrollDC: dx=%d, dy=%d, rc=%ld,%ld,%ld,%ld\n", dx
, dy
,
64 (LONG
)rc
->left
, (LONG
)rc
->top
, (LONG
)rc
->right
, (LONG
)rc
->bottom
);
71 hrgnClip
= CreateRectRgnIndirect(cliprc
);
72 SelectClipRgn(hdc
, hrgnClip
);
77 src
.x
= XDPTOLP(dc
, rc
->left
);
78 dest
.x
= XDPTOLP(dc
, rc
->left
+ abs(dx
));
82 src
.x
= XDPTOLP(dc
, rc
->left
+ abs(dx
));
83 dest
.x
= XDPTOLP(dc
, rc
->left
);
87 src
.y
= YDPTOLP(dc
, rc
->top
);
88 dest
.y
= YDPTOLP(dc
, rc
->top
+ abs(dy
));
92 src
.y
= YDPTOLP(dc
, rc
->top
+ abs(dy
));
93 dest
.y
= YDPTOLP(dc
, rc
->top
);
96 width
= rc
->right
- rc
->left
- abs(dx
);
97 height
= rc
->bottom
- rc
->top
- abs(dy
);
99 if (!BitBlt(hdc
, dest
.x
, dest
.y
, width
, height
, hdc
, src
.x
, src
.y
,
106 hrgn1
= CreateRectRgn(rc
->left
, rc
->top
, rc
->left
+dx
, rc
->bottom
);
108 hrgn1
= CreateRectRgn(rc
->right
+dx
, rc
->top
, rc
->right
,
111 hrgn1
= CreateRectRgn(0, 0, 0, 0);
114 hrgn2
= CreateRectRgn(rc
->left
, rc
->top
, rc
->right
, rc
->top
+dy
);
116 hrgn2
= CreateRectRgn(rc
->left
, rc
->bottom
+dy
, rc
->right
,
119 hrgn2
= CreateRectRgn(0, 0, 0, 0);
121 RgnType
= CombineRgn(hrgnUpdate
, hrgn1
, hrgn2
, RGN_OR
);
124 if (rcUpdate
) GetRgnBox( hrgnUpdate
, rcUpdate
);
129 /*************************************************************************
130 * ScrollWindowEx (USER.319)
133 int ScrollWindowEx(HWND hwnd
, short dx
, short dy
, LPRECT rect
, LPRECT clipRect
,
134 HRGN hrgnUpdate
, LPRECT rcUpdate
, WORD flags
)
139 dprintf_scroll(stddeb
,"ScrollWindowEx: dx=%d, dy=%d, rect=%ld,%ld,%ld,%ld\n",
140 dx
, dy
, (LONG
)rect
->left
, (LONG
)rect
->top
, (LONG
)rect
->right
,
146 GetClientRect(hwnd
, &rc
);
149 if (clipRect
== NULL
)
150 GetClientRect(hwnd
, &cliprc
);
152 CopyRect(&cliprc
, clipRect
);
154 ScrollDC(hdc
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
156 if (flags
| SW_INVALIDATE
)
158 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, RDW_INVALIDATE
| RDW_ERASE
|
159 ((flags
& SW_ERASE
) ? RDW_ERASENOW
: 0));
162 ReleaseDC(hwnd
, hdc
);