2 * Scroll windows and DCs
4 * Copyright David W. Metcalfe, 1993
8 static char Copyright[] = "Copyright David W. Metcalfe, 1993";
17 /*************************************************************************
18 * ScrollWindow (USER.61)
21 void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect)
28 printf("ScrollWindow: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", dx, dy,
29 rect->left, rect->top, rect->right, rect->bottom);
35 GetWindowRect(hwnd, &rc);
39 GetWindowRect(hwnd, &cliprc);
41 CopyRect(&cliprc, clipRect);
43 hrgnUpdate = CreateRectRgn(0, 0, 0, 0);
44 ScrollDC(hdc, dx, dy, &rc, &cliprc, hrgnUpdate, NULL);
45 InvalidateRgn(hwnd, hrgnUpdate, TRUE);
50 /*************************************************************************
54 BOOL ScrollDC(HDC hdc, short dx, short dy, LPRECT rc, LPRECT cliprc,
55 HRGN hrgnUpdate, LPRECT rcUpdate)
57 HRGN hrgnClip, hrgn1, hrgn2;
60 DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
63 printf("ScrollDC: dx=%d, dy=%d, rc=%d,%d,%d,%d\n", dx, dy,
64 rc->left, rc->top, rc->right, rc->bottom);
72 hrgnClip = CreateRectRgnIndirect(cliprc);
73 SelectClipRgn(hdc, hrgnClip);
78 src.x = XDPTOLP(dc, rc->left);
79 dest.x = XDPTOLP(dc, rc->left + abs(dx));
83 src.x = XDPTOLP(dc, rc->left + abs(dx));
84 dest.x = XDPTOLP(dc, rc->left);
88 src.y = YDPTOLP(dc, rc->top);
89 dest.y = YDPTOLP(dc, rc->top + abs(dy));
93 src.y = YDPTOLP(dc, rc->top + abs(dy));
94 dest.y = YDPTOLP(dc, rc->top);
97 width = rc->right - rc->left - abs(dx);
98 height = rc->bottom - rc->top - abs(dy);
100 if (!BitBlt(hdc, dest.x, dest.y, width, height, hdc, src.x, src.y,
107 hrgn1 = CreateRectRgn(rc->left, rc->top, rc->left+dx, rc->bottom);
109 hrgn1 = CreateRectRgn(rc->right+dx, rc->top, rc->right,
112 hrgn1 = CreateRectRgn(0, 0, 0, 0);
115 hrgn2 = CreateRectRgn(rc->left, rc->top, rc->right, rc->top+dy);
117 hrgn2 = CreateRectRgn(rc->left, rc->bottom+dy, rc->right,
120 hrgn2 = CreateRectRgn(0, 0, 0, 0);
122 RgnType = CombineRgn(hrgnUpdate, hrgn1, hrgn2, RGN_OR);
127 SelectClipRgn(hdc, hrgnUpdate);
128 GetClipBox(hdc, rcUpdate);
133 /*************************************************************************
134 * ScrollWindowEx (USER.319)
137 int ScrollWindowEx(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect,
138 HRGN hrgnUpdate, LPRECT rcUpdate, WORD flags)
144 printf("ScrollWindowEx: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", dx, dy,
145 rect->left, rect->top, rect->right, rect->bottom);
151 GetWindowRect(hwnd, &rc);
154 if (clipRect == NULL)
155 GetWindowRect(hwnd, &cliprc);
157 CopyRect(&cliprc, clipRect);
159 ScrollDC(hdc, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate);
161 if (flags | SW_INVALIDATE)
163 InvalidateRgn(hwnd, hrgnUpdate, FALSE);
165 if (flags | SW_ERASE)
166 SendMessage(hwnd, WM_ERASEBKGND, (WORD)hdc, (LONG)NULL);
169 ReleaseDC(hwnd, hdc);