1 | /* $Id: dc.cpp,v 1.126 2004-02-23 12:03:05 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * DC functions for USER32
|
---|
5 | *
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | *
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*****************************************************************************
|
---|
11 | * Includes *
|
---|
12 | *****************************************************************************/
|
---|
13 |
|
---|
14 | #include <odin.h>
|
---|
15 |
|
---|
16 | #define INCL_WIN
|
---|
17 | #define INCL_GPI
|
---|
18 | #define INCL_GREALL
|
---|
19 | #define INCL_DEV
|
---|
20 | #include <os2wrap.h>
|
---|
21 | //#include <pmddi.h>
|
---|
22 | #include <stdlib.h>
|
---|
23 |
|
---|
24 | #include <string.h>
|
---|
25 | #include <win32type.h>
|
---|
26 | #include <win32api.h>
|
---|
27 | #include <winuser32.h>
|
---|
28 | #include <winconst.h>
|
---|
29 | #include <misc.h>
|
---|
30 | #include <win32wbase.h>
|
---|
31 | #include <math.h>
|
---|
32 | #include <limits.h>
|
---|
33 | #include "oslibwin.h"
|
---|
34 | #include "oslibmsg.h"
|
---|
35 | #include <dcdata.h>
|
---|
36 | #include <codepage.h>
|
---|
37 | #include <wingdi32.h>
|
---|
38 | #include <stats.h>
|
---|
39 |
|
---|
40 | #define INCLUDED_BY_DC
|
---|
41 | #include "dc.h"
|
---|
42 |
|
---|
43 | #define DBG_LOCALLOG DBG_dc
|
---|
44 | #include "dbglocal.h"
|
---|
45 |
|
---|
46 | #ifndef DEVESC_SETPS
|
---|
47 | #define DEVESC_SETPS 49149L
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #define FLOAT_TO_FIXED(x) ((FIXED) ((x) * 65536.0))
|
---|
51 | #define MICRO_HPS_TO_HDC(x) ((x) & 0xFFFFFFFE)
|
---|
52 |
|
---|
53 | #define PMRECT_FROM_WINRECT( pmRect, winRect ) \
|
---|
54 | { \
|
---|
55 | (pmRect).xLeft = (winRect).left; \
|
---|
56 | (pmRect).yBottom = (winRect).bottom; \
|
---|
57 | (pmRect).xRight = (winRect).right; \
|
---|
58 | (pmRect).yTop = (winRect).top; \
|
---|
59 | }
|
---|
60 |
|
---|
61 | #define WINRECT_FROM_PMRECT( winRect, pmRect ) \
|
---|
62 | { \
|
---|
63 | (winRect).left = (pmRect).xLeft; \
|
---|
64 | (winRect).top = (pmRect).yTop; \
|
---|
65 | (winRect).right = (pmRect).xRight; \
|
---|
66 | (winRect).bottom = (pmRect).yBottom; \
|
---|
67 | }
|
---|
68 |
|
---|
69 | #define MEM_HPS_MAX 768
|
---|
70 |
|
---|
71 | const XFORM_W XFORMIdentity = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
|
---|
72 | const MATRIXLF matrixlfIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0};
|
---|
73 |
|
---|
74 | BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps);
|
---|
75 | BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev);
|
---|
76 | LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps);
|
---|
77 |
|
---|
78 | #ifdef DEBUG
|
---|
79 | #define dprintfRegion(a,b,c) if(DbgEnabledLvl2USER32[DBG_LOCALLOG] == 1) dprintfRegion1(a,b,c)
|
---|
80 | //#define dprintfRegion(a,b,c) dprintfRegion1(a,b,c)
|
---|
81 |
|
---|
82 | void dprintfRegion1(HPS hps, HWND hWnd, HRGN hrgnClip)
|
---|
83 | {
|
---|
84 | RGNRECT rgnRect = {0, 16, 0, RECTDIR_LFRT_TOPBOT};
|
---|
85 | RECTL rectRegion[16];
|
---|
86 | APIRET rc;
|
---|
87 |
|
---|
88 | dprintf(("dprintfRegion %x %x", hWnd, hps));
|
---|
89 | rc = GpiQueryRegionRects(hps, hrgnClip, NULL, &rgnRect, &rectRegion[0]);
|
---|
90 | for(int i=0;i<rgnRect.crcReturned;i++) {
|
---|
91 | dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop));
|
---|
92 | }
|
---|
93 | }
|
---|
94 | #else
|
---|
95 | #define dprintfRegion(a,b,c)
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | //******************************************************************************
|
---|
99 | //******************************************************************************
|
---|
100 | void WIN32API TestWideLine (pDCData pHps)
|
---|
101 | {
|
---|
102 | const LOGPEN_W *pLogPen;
|
---|
103 |
|
---|
104 | pHps->isWideLine = FALSE;
|
---|
105 | pLogPen = pHps->penIsExtPen ?
|
---|
106 | &(pHps->lastPenObject->ExtPen.logpen) :
|
---|
107 | &(pHps->lastPenObject->Pen.logpen);
|
---|
108 |
|
---|
109 | if (((pLogPen->lopnStyle & PS_STYLE_MASK_W) != PS_NULL_W) &&
|
---|
110 | (pLogPen->lopnWidth.x > 0))
|
---|
111 | {
|
---|
112 | POINTL aptl[2] = { 0, 0, pLogPen->lopnWidth.x, pLogPen->lopnWidth.x };
|
---|
113 |
|
---|
114 | GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, aptl);
|
---|
115 |
|
---|
116 | ULONG dx = abs(aptl[0].x - aptl[1].x);
|
---|
117 | ULONG dy = abs(aptl[0].y - aptl[1].y);
|
---|
118 |
|
---|
119 | pHps->isWideLine = (dx > 1) || (dy > 1);
|
---|
120 | }
|
---|
121 | }
|
---|
122 | //******************************************************************************
|
---|
123 | //******************************************************************************
|
---|
124 | void WIN32API Calculate1PixelDelta(pDCData pHps)
|
---|
125 | {
|
---|
126 | POINTL aptl[2] = {0, 0, 1, 1};
|
---|
127 |
|
---|
128 | GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, aptl);
|
---|
129 | pHps->worldYDeltaFor1Pixel = (int)(aptl[1].y - aptl[0].y);
|
---|
130 | pHps->worldXDeltaFor1Pixel = (int)(aptl[1].x - aptl[0].x); // 171182
|
---|
131 | }
|
---|
132 | //******************************************************************************
|
---|
133 | //******************************************************************************
|
---|
134 | int setMapMode(Win32BaseWindow *wnd, pDCData pHps, int mode)
|
---|
135 | {
|
---|
136 | int prevMode = 0;
|
---|
137 | ULONG flOptions;
|
---|
138 |
|
---|
139 | switch (mode)
|
---|
140 | {
|
---|
141 | case MM_HIENGLISH_W : flOptions = PU_HIENGLISH; break;
|
---|
142 | case MM_LOENGLISH_W : flOptions = PU_LOENGLISH; break;
|
---|
143 | case MM_HIMETRIC_W : flOptions = PU_HIMETRIC ; break;
|
---|
144 | case MM_LOMETRIC_W : flOptions = PU_LOMETRIC ; break;
|
---|
145 | case MM_TEXT_W : flOptions = PU_PELS ; break;
|
---|
146 | case MM_TWIPS_W : flOptions = PU_TWIPS ; break;
|
---|
147 | case MM_ANISOTROPIC_W: flOptions = PU_PELS ; break;
|
---|
148 | case MM_ISOTROPIC_W : flOptions = PU_LOMETRIC ; break;
|
---|
149 | default:
|
---|
150 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
151 | return FALSE;
|
---|
152 | }
|
---|
153 |
|
---|
154 | prevMode = pHps->MapMode; /* store previous mode */
|
---|
155 | pHps->MapMode = mode;
|
---|
156 |
|
---|
157 | if (mode == MM_TEXT_W)
|
---|
158 | {
|
---|
159 | pHps->viewportXExt =
|
---|
160 | pHps->viewportYExt = 1.0;
|
---|
161 | pHps->windowExt.cx =
|
---|
162 | pHps->windowExt.cy = 1;
|
---|
163 | }
|
---|
164 | else if (mode != MM_ANISOTROPIC_W)
|
---|
165 | {
|
---|
166 | RECTL rectl;
|
---|
167 | SIZEL sizel;
|
---|
168 | ULONG data[3];
|
---|
169 |
|
---|
170 | data[0] = flOptions;
|
---|
171 | data[1] = data[2] = 0;
|
---|
172 |
|
---|
173 | if (DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0) == DEVESC_ERROR)
|
---|
174 | {
|
---|
175 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
176 | return 0;
|
---|
177 | }
|
---|
178 |
|
---|
179 | GpiQueryPageViewport(pHps->hps, &rectl);
|
---|
180 | pHps->viewportXExt = (double)rectl.xRight;
|
---|
181 | pHps->viewportYExt = -(double)rectl.yTop;
|
---|
182 |
|
---|
183 | GreGetPageUnits(pHps->hdc? pHps->hdc : pHps->hps, &sizel);
|
---|
184 | pHps->windowExt.cx = sizel.cx;
|
---|
185 | pHps->windowExt.cy = sizel.cy;
|
---|
186 |
|
---|
187 | data[0] = PU_PELS;
|
---|
188 | DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0);
|
---|
189 | }
|
---|
190 |
|
---|
191 | if (((prevMode != MM_ISOTROPIC_W) && (prevMode != MM_ANISOTROPIC_W)) &&
|
---|
192 | ((mode == MM_ISOTROPIC_W) || (mode == MM_ANISOTROPIC_W)))
|
---|
193 | {
|
---|
194 | if (pHps->lWndXExtSave && pHps->lWndYExtSave)
|
---|
195 | {
|
---|
196 | changePageXForm (wnd, pHps, (PPOINTL)&pHps->windowExt,
|
---|
197 | pHps->lWndXExtSave, pHps->lWndYExtSave, NULL );
|
---|
198 | pHps->lWndXExtSave = pHps->lWndYExtSave = 0;
|
---|
199 | }
|
---|
200 | if (pHps->lVwpXExtSave && pHps->lVwpYExtSave)
|
---|
201 | {
|
---|
202 | changePageXForm (wnd, pHps, NULL,
|
---|
203 | pHps->lVwpXExtSave, pHps->lVwpYExtSave, NULL );
|
---|
204 | pHps->lVwpXExtSave = pHps->lVwpYExtSave = 0;
|
---|
205 | }
|
---|
206 | }
|
---|
207 |
|
---|
208 | setPageXForm(wnd, pHps);
|
---|
209 |
|
---|
210 | return prevMode;
|
---|
211 | }
|
---|
212 | //******************************************************************************
|
---|
213 | //******************************************************************************
|
---|
214 | BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps)
|
---|
215 | {
|
---|
216 | MATRIXLF mlf;
|
---|
217 | BOOL rc = TRUE;
|
---|
218 |
|
---|
219 | pHps->height = clientHeight(wnd, 0, pHps) - 1;
|
---|
220 |
|
---|
221 | double xScale = pHps->viewportXExt / (double)pHps->windowExt.cx;
|
---|
222 | double yScale = pHps->viewportYExt / (double)pHps->windowExt.cy;
|
---|
223 |
|
---|
224 | #if 0
|
---|
225 | mlf.fxM11 = FLOAT_TO_FIXED(1.0);
|
---|
226 | mlf.fxM12 = 0;
|
---|
227 | mlf.lM13 = 0;
|
---|
228 | mlf.fxM21 = 0;
|
---|
229 | mlf.fxM22 = FLOAT_TO_FIXED(1.0);
|
---|
230 | mlf.lM23 = 0;
|
---|
231 | mlf.lM31 = pHps->viewportOrg.x - (LONG)(pHps->windowOrg.x * xScale);
|
---|
232 | mlf.lM32 = pHps->viewportOrg.y - (LONG)(pHps->windowOrg.y * yScale);
|
---|
233 | mlf.lM33 = 1;
|
---|
234 |
|
---|
235 | //testestest
|
---|
236 | if(wnd && wnd->getWindowWidth() && wnd->getWindowHeight())
|
---|
237 | {
|
---|
238 | RECTL recttmp, rectviewold;
|
---|
239 |
|
---|
240 | rc = GpiQueryPageViewport(pHps->hps, &rectviewold);
|
---|
241 | if(rc == 0) {
|
---|
242 | dprintf(("WARNING: GpiQueryPageViewport returned FALSE!!"));
|
---|
243 | }
|
---|
244 | recttmp.xLeft = 0;
|
---|
245 | recttmp.xRight = ((double)GetScreenWidth() / xScale);
|
---|
246 | recttmp.yBottom = 0;
|
---|
247 | recttmp.yTop = ((double)GetScreenHeight() / yScale);
|
---|
248 |
|
---|
249 | if(recttmp.yTop != rectviewold.yTop ||
|
---|
250 | recttmp.xRight != rectviewold.xRight)
|
---|
251 | {
|
---|
252 | if(pHps->viewportYExt > pHps->windowExt.cy) {//scaling up means we have to invert the y values
|
---|
253 | recttmp.yBottom = GetScreenHeight() - recttmp.yTop;
|
---|
254 | recttmp.yTop = GetScreenHeight();
|
---|
255 | }
|
---|
256 | dprintf(("GpiSetPageViewport %x (%d,%d)(%d,%d) %f %f", pHps->hps, recttmp.xLeft, recttmp.yBottom, recttmp.xRight, recttmp.yTop, xScale, yScale));
|
---|
257 | rc = GpiSetPageViewport(pHps->hps, &recttmp);
|
---|
258 | if(rc == 0) {
|
---|
259 | dprintf(("WARNING: GpiSetPageViewport returned FALSE!!"));
|
---|
260 | }
|
---|
261 | }
|
---|
262 | }
|
---|
263 | //testestest
|
---|
264 |
|
---|
265 | #else
|
---|
266 | mlf.fxM11 = FLOAT_TO_FIXED(xScale);
|
---|
267 | mlf.fxM12 = 0;
|
---|
268 | mlf.lM13 = 0;
|
---|
269 | mlf.fxM21 = 0;
|
---|
270 | mlf.fxM22 = FLOAT_TO_FIXED(yScale);
|
---|
271 | mlf.lM23 = 0;
|
---|
272 | mlf.lM31 = pHps->viewportOrg.x - (LONG)(pHps->windowOrg.x * xScale);
|
---|
273 | mlf.lM32 = pHps->viewportOrg.y - (LONG)(pHps->windowOrg.y * yScale);
|
---|
274 | mlf.lM33 = 1;
|
---|
275 | #endif
|
---|
276 |
|
---|
277 | pHps->isLeftLeft = mlf.fxM11 >= 0;
|
---|
278 | pHps->isTopTop = mlf.fxM22 >= 0;
|
---|
279 |
|
---|
280 | BOOL bEnableYInversion = FALSE;
|
---|
281 | if ((mlf.fxM22 > 0) ||
|
---|
282 | ((pHps->graphicsMode == GM_ADVANCED_W) &&
|
---|
283 | ((pHps->MapMode == MM_ANISOTROPIC_W) ||
|
---|
284 | (pHps->MapMode == MM_ISOTROPIC_W))))
|
---|
285 | {
|
---|
286 | bEnableYInversion = TRUE;
|
---|
287 | }
|
---|
288 | else
|
---|
289 | {
|
---|
290 | bEnableYInversion = FALSE;
|
---|
291 | mlf.lM32 = pHps->HPStoHDCInversionHeight + pHps->height - mlf.lM32;
|
---|
292 | mlf.fxM22 = -mlf.fxM22;
|
---|
293 | }
|
---|
294 |
|
---|
295 | if (!pHps->isMetaPS)
|
---|
296 | // if ((!pHps->isMetaPS) ||
|
---|
297 | // (pHps->pMetaFileObject && pHps->pMetaFileObject->isEnhanced()))
|
---|
298 | rc = GpiSetDefaultViewMatrix(pHps->hps, 8, &mlf, TRANSFORM_REPLACE);
|
---|
299 | if(rc == 0) {
|
---|
300 | dprintf(("WARNING: GpiSetDefaultViewMatrix returned FALSE!!"));
|
---|
301 | }
|
---|
302 | #ifdef INVERT
|
---|
303 | if (bEnableYInversion)
|
---|
304 | GpiEnableYInversion(pHps->hps, pHps->height + pHps->HPStoHDCInversionHeight);
|
---|
305 | else
|
---|
306 | GpiEnableYInversion(pHps->hps, 0);
|
---|
307 | #else
|
---|
308 | pHps->yInvert = 0;
|
---|
309 | if(bEnableYInversion)
|
---|
310 | {
|
---|
311 | pHps->yInvert4Enable = pHps->height + pHps->HPStoHDCInversionHeight;
|
---|
312 | if(pHps->isPrinter)
|
---|
313 | {
|
---|
314 | pHps->yInvert = pHps->yInvert4Enable
|
---|
315 | * (pHps->windowExt.cy / (double)pHps->viewportYExt);
|
---|
316 | } else {
|
---|
317 | pHps->yInvert = pHps->yInvert4Enable;
|
---|
318 | }
|
---|
319 | }
|
---|
320 | #endif
|
---|
321 |
|
---|
322 | TestWideLine(pHps);
|
---|
323 | Calculate1PixelDelta(pHps);
|
---|
324 | return rc;
|
---|
325 | }
|
---|
326 | //******************************************************************************
|
---|
327 | //******************************************************************************
|
---|
328 | BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)
|
---|
329 | {
|
---|
330 | BOOL result = FALSE;
|
---|
331 |
|
---|
332 | if (pValue)
|
---|
333 | {
|
---|
334 | if (pPrev)
|
---|
335 | *pPrev = *pValue;
|
---|
336 |
|
---|
337 | if ((pValue->x == x) && (pValue->y == y)) {
|
---|
338 | return TRUE;
|
---|
339 | }
|
---|
340 | pValue->x = x;
|
---|
341 | pValue->y = y;
|
---|
342 | }
|
---|
343 | else
|
---|
344 | {
|
---|
345 | if (pPrev)
|
---|
346 | {
|
---|
347 | pPrev->x = (int)pHps->viewportXExt;
|
---|
348 | pPrev->y = (int)pHps->viewportYExt;
|
---|
349 | }
|
---|
350 | pHps->viewportXExt = (double)x;
|
---|
351 | pHps->viewportYExt = (double)y;
|
---|
352 | }
|
---|
353 |
|
---|
354 | if (pHps->MapMode == MM_ISOTROPIC_W)
|
---|
355 | {
|
---|
356 | double xExt = fabs(pHps->viewportXExt);
|
---|
357 | double yExt = fabs(pHps->viewportYExt);
|
---|
358 | double sf = fabs((double)pHps->windowExt.cx / pHps->windowExt.cy);
|
---|
359 |
|
---|
360 | if (xExt > (yExt * sf))
|
---|
361 | {
|
---|
362 | xExt = yExt * sf;
|
---|
363 |
|
---|
364 | if ((double)LONG_MAX <= xExt) return (result);
|
---|
365 |
|
---|
366 | if (pHps->viewportXExt < 0.0)
|
---|
367 | pHps->viewportXExt = -xExt;
|
---|
368 | else
|
---|
369 | pHps->viewportXExt = xExt;
|
---|
370 | }
|
---|
371 | else
|
---|
372 | {
|
---|
373 | yExt = xExt / sf;
|
---|
374 |
|
---|
375 | if ((double)LONG_MAX <= yExt) return (result);
|
---|
376 |
|
---|
377 | if (pHps->viewportYExt < 0.0)
|
---|
378 | pHps->viewportYExt = -yExt;
|
---|
379 | else
|
---|
380 | pHps->viewportYExt = yExt;
|
---|
381 | }
|
---|
382 | }
|
---|
383 | result = setPageXForm(wnd, pHps);
|
---|
384 |
|
---|
385 | return (result);
|
---|
386 | }
|
---|
387 | //******************************************************************************
|
---|
388 | //******************************************************************************
|
---|
389 | VOID removeClientArea(Win32BaseWindow *window, pDCData pHps)
|
---|
390 | {
|
---|
391 | pHps->isClient = FALSE;
|
---|
392 | pHps->isClientArea = FALSE;
|
---|
393 | }
|
---|
394 | //******************************************************************************
|
---|
395 | //******************************************************************************
|
---|
396 | void selectClientArea(Win32BaseWindow *window, pDCData pHps)
|
---|
397 | {
|
---|
398 | pHps->isClient = TRUE;
|
---|
399 | pHps->isClientArea = TRUE;
|
---|
400 | }
|
---|
401 | //******************************************************************************
|
---|
402 | //******************************************************************************
|
---|
403 | void selectClientArea(Win32BaseWindow *wnd, HDC hdc)
|
---|
404 | {
|
---|
405 | pDCData pHps = (pDCData)GpiQueryDCData (wnd->getOwnDC());
|
---|
406 |
|
---|
407 | if (pHps != NULLHANDLE)
|
---|
408 | selectClientArea(wnd, pHps);
|
---|
409 | }
|
---|
410 | //******************************************************************************
|
---|
411 | //******************************************************************************
|
---|
412 | LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps)
|
---|
413 | {
|
---|
414 | if ((hwnd == 0) && (pHps != 0))
|
---|
415 | hwnd = pHps->hwnd;
|
---|
416 |
|
---|
417 | if ((hwnd != 0) || (pHps == 0))
|
---|
418 | {
|
---|
419 | if(wnd) {
|
---|
420 | if(pHps && !pHps->isClientArea) {
|
---|
421 | return (wnd->getWindowHeight());
|
---|
422 | }
|
---|
423 | else return (wnd->getClientHeight());
|
---|
424 | }
|
---|
425 | else return OSLibQueryScreenHeight();
|
---|
426 | }
|
---|
427 | else if (pHps->bitmapHandle)
|
---|
428 | {
|
---|
429 | return pHps->bitmapHeight;
|
---|
430 | }
|
---|
431 | else if (pHps->isMetaPS)
|
---|
432 | {
|
---|
433 | return 0;
|
---|
434 | }
|
---|
435 | else if (pHps->isPrinter)
|
---|
436 | {
|
---|
437 | return pHps->printPageHeight;
|
---|
438 | }
|
---|
439 | else
|
---|
440 | {
|
---|
441 | return MEM_HPS_MAX;
|
---|
442 | }
|
---|
443 | }
|
---|
444 | //******************************************************************************
|
---|
445 | //******************************************************************************
|
---|
446 | BOOL WIN32API changePageXForm(pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)
|
---|
447 | {
|
---|
448 | Win32BaseWindow *wnd;
|
---|
449 |
|
---|
450 | if(pHps->isClient) {
|
---|
451 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
452 | }
|
---|
453 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
454 | BOOL ret = changePageXForm(wnd, pHps, pValue, x, y, pPrev);
|
---|
455 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
456 | return ret;
|
---|
457 | }
|
---|
458 | //******************************************************************************
|
---|
459 | //******************************************************************************
|
---|
460 | BOOL WIN32API setPageXForm(pDCData pHps)
|
---|
461 | {
|
---|
462 | Win32BaseWindow *wnd;
|
---|
463 |
|
---|
464 | if(pHps->isClient) {
|
---|
465 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
466 | }
|
---|
467 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
468 | BOOL ret = setPageXForm(wnd, pHps);
|
---|
469 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
470 | return ret;
|
---|
471 | }
|
---|
472 | //******************************************************************************
|
---|
473 | //******************************************************************************
|
---|
474 | VOID WIN32API removeClientArea(pDCData pHps)
|
---|
475 | {
|
---|
476 | Win32BaseWindow *wnd;
|
---|
477 |
|
---|
478 | if(pHps->isClient) {
|
---|
479 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
480 | }
|
---|
481 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
482 | if(wnd) {
|
---|
483 | removeClientArea(wnd, pHps);
|
---|
484 | RELEASE_WNDOBJ(wnd);
|
---|
485 | }
|
---|
486 | }
|
---|
487 | //******************************************************************************
|
---|
488 | //******************************************************************************
|
---|
489 | VOID WIN32API selectClientArea(pDCData pHps)
|
---|
490 | {
|
---|
491 | Win32BaseWindow *wnd;
|
---|
492 |
|
---|
493 | if(pHps->isClient) {
|
---|
494 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
495 | }
|
---|
496 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
497 | if(wnd) {
|
---|
498 | selectClientArea(wnd, pHps);
|
---|
499 | RELEASE_WNDOBJ(wnd);
|
---|
500 | }
|
---|
501 | }
|
---|
502 | //******************************************************************************
|
---|
503 | //******************************************************************************
|
---|
504 | VOID WIN32API checkOrigin(pDCData pHps)
|
---|
505 | {
|
---|
506 | Win32BaseWindow *wnd;
|
---|
507 |
|
---|
508 | if(pHps->isClient) {
|
---|
509 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
510 | }
|
---|
511 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
512 | if(wnd) {
|
---|
513 | if(pHps->isClient)
|
---|
514 | selectClientArea(wnd, pHps);
|
---|
515 | RELEASE_WNDOBJ(wnd);
|
---|
516 | }
|
---|
517 | }
|
---|
518 | //******************************************************************************
|
---|
519 | //******************************************************************************
|
---|
520 | LONG WIN32API clientHeight(HWND hwnd, pDCData pHps)
|
---|
521 | {
|
---|
522 | Win32BaseWindow *wnd;
|
---|
523 |
|
---|
524 | if(!pHps) {
|
---|
525 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
526 | }
|
---|
527 | else
|
---|
528 | if(pHps->isClient) {
|
---|
529 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
530 | }
|
---|
531 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
532 | LONG ret = clientHeight(wnd, hwnd, pHps);
|
---|
533 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
534 | return ret;
|
---|
535 | }
|
---|
536 | //******************************************************************************
|
---|
537 | //******************************************************************************
|
---|
538 | int WIN32API setMapModeDC(pDCData pHps, int mode)
|
---|
539 | {
|
---|
540 | Win32BaseWindow *wnd;
|
---|
541 |
|
---|
542 | if(pHps->isClient) {
|
---|
543 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
|
---|
544 | }
|
---|
545 | else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
|
---|
546 | int ret = setMapMode(wnd, pHps, mode);
|
---|
547 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
548 | return ret;
|
---|
549 | }
|
---|
550 | //******************************************************************************
|
---|
551 | //******************************************************************************
|
---|
552 | BOOL isYup (pDCData pHps)
|
---|
553 | {
|
---|
554 | if (((pHps->windowExt.cy < 0) && (pHps->viewportYExt > 0.0)) ||
|
---|
555 | ((pHps->windowExt.cy > 0) && (pHps->viewportYExt < 0.0)))
|
---|
556 | {
|
---|
557 | if ((pHps->graphicsMode == GM_COMPATIBLE_W) ||
|
---|
558 | ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 >= 0.0)))
|
---|
559 | return TRUE;
|
---|
560 | }
|
---|
561 | else
|
---|
562 | {
|
---|
563 | if ((pHps->graphicsMode == GM_ADVANCED_W) && (pHps->xform.eM22 < 0.0))
|
---|
564 | return TRUE;
|
---|
565 | }
|
---|
566 | return FALSE;
|
---|
567 | }
|
---|
568 | //******************************************************************************
|
---|
569 | //******************************************************************************
|
---|
570 | INT revertDy (Win32BaseWindow *wnd, INT dy)
|
---|
571 | {
|
---|
572 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
573 | // if (wnd->isOwnDC() && wnd->getOwnDC())
|
---|
574 | if (wnd->isOwnDC())
|
---|
575 | {
|
---|
576 | pDCData pHps = (pDCData)GpiQueryDCData (wnd->getOwnDC());
|
---|
577 |
|
---|
578 | if (pHps != NULLHANDLE)
|
---|
579 | if (!isYup (pHps))
|
---|
580 | dy = -dy;
|
---|
581 | }
|
---|
582 | else
|
---|
583 | {
|
---|
584 | dy = -dy;
|
---|
585 | }
|
---|
586 | return (dy);
|
---|
587 | }
|
---|
588 | //******************************************************************************
|
---|
589 | //******************************************************************************
|
---|
590 | HDC sendEraseBkgnd (Win32BaseWindow *wnd)
|
---|
591 | {
|
---|
592 | BOOL erased;
|
---|
593 | HWND hwnd;
|
---|
594 | HDC hdc;
|
---|
595 | HPS hps;
|
---|
596 | HRGN hrgnUpdate;
|
---|
597 | RECTL rectl = { 1, 1, 2, 2 };
|
---|
598 | pDCData pHps = NULLHANDLE;
|
---|
599 |
|
---|
600 | hwnd = wnd->getOS2WindowHandle();
|
---|
601 | hps = WinGetPS(hwnd);
|
---|
602 |
|
---|
603 | hrgnUpdate = GpiCreateRegion (hps, 1, &rectl);
|
---|
604 | WinQueryUpdateRegion (hwnd, hrgnUpdate);
|
---|
605 |
|
---|
606 | hdc = HPSToHDC (hwnd, hps, NULL, NULL);
|
---|
607 |
|
---|
608 | pHps = (pDCData)GpiQueryDCData(hps);
|
---|
609 | GdiSetVisRgn(pHps, hrgnUpdate);
|
---|
610 |
|
---|
611 | erased = wnd->MsgEraseBackGround (hdc);
|
---|
612 |
|
---|
613 | //hrgnUpdate is destroyed in DeleteHDC
|
---|
614 | DeleteHDC (hdc);
|
---|
615 | WinReleasePS (hps);
|
---|
616 |
|
---|
617 | return erased;
|
---|
618 | }
|
---|
619 | //******************************************************************************
|
---|
620 | //******************************************************************************
|
---|
621 | HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
|
---|
622 | {
|
---|
623 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
---|
624 | pDCData pHps = NULLHANDLE;
|
---|
625 | HPS hPS_ownDC = NULLHANDLE, hpsPaint = 0;
|
---|
626 | RECTL rectl = {0, 0, 1, 1};
|
---|
627 | HRGN hrgnOldClip;
|
---|
628 | LONG lComplexity;
|
---|
629 | RECTL rectlClient;
|
---|
630 | RECTL rectlClip;
|
---|
631 | BOOL bIcon;
|
---|
632 |
|
---|
633 | if(lpps == NULL) {
|
---|
634 | //BeginPaint does NOT change last error in this case
|
---|
635 | //(verified in NT4, SP6)
|
---|
636 | dprintf (("USER32: BeginPaint %x NULL PAINTSTRUCT pointer", hWnd));
|
---|
637 | return 0;
|
---|
638 | }
|
---|
639 | memset(lpps, 0, sizeof(*lpps));
|
---|
640 |
|
---|
641 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
642 | if(!wnd) {
|
---|
643 | dprintf (("USER32: BeginPaint %x %x: invalid window handle!!", hWnd, lpps));
|
---|
644 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); //(verified in NT4, SP6)
|
---|
645 | return (HDC)0;
|
---|
646 | }
|
---|
647 | bIcon = IsIconic(hwnd);
|
---|
648 |
|
---|
649 | //check if the application previously didn't handle a WM_PAINT msg properly
|
---|
650 | wnd->checkForDirtyUpdateRegion();
|
---|
651 |
|
---|
652 | HWND hwndClient = (bIcon) ? wnd->getOS2FrameWindowHandle() : wnd->getOS2WindowHandle();
|
---|
653 |
|
---|
654 | if(hwnd != HWND_DESKTOP && !bIcon && wnd->isOwnDC())
|
---|
655 | {
|
---|
656 | hPS_ownDC = wnd->getOwnDC();
|
---|
657 | //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
|
---|
658 | if(hPS_ownDC) {
|
---|
659 | pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
|
---|
660 | if (!pHps)
|
---|
661 | {
|
---|
662 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
---|
663 | RELEASE_WNDOBJ(wnd);
|
---|
664 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
665 | return (HDC)NULLHANDLE;
|
---|
666 | }
|
---|
667 | hpsPaint = hPS_ownDC;
|
---|
668 | STATS_GetDCEx(hwnd, hpsPaint, 0, 0);
|
---|
669 | }
|
---|
670 | }
|
---|
671 | if(!hpsPaint) {
|
---|
672 | hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_USESTYLE_W | ((bIcon) ? DCX_WINDOW_W : 0)));
|
---|
673 | pHps = (pDCData)GpiQueryDCData(hpsPaint);
|
---|
674 | if (!pHps)
|
---|
675 | {
|
---|
676 | dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
|
---|
677 | RELEASE_WNDOBJ(wnd);
|
---|
678 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
679 | return (HDC)NULLHANDLE;
|
---|
680 | }
|
---|
681 | }
|
---|
682 |
|
---|
683 | if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE)
|
---|
684 | {
|
---|
685 | memset(&rectl, 0, sizeof(rectl));
|
---|
686 | dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
|
---|
687 |
|
---|
688 | if(bIcon) {
|
---|
689 | //WinBeginPaint messes this up for icon windows; this isn't
|
---|
690 | //a good solution, but it does the job
|
---|
691 | //Use the entire frame window as clip region
|
---|
692 | rectl.xRight = wnd->getWindowWidth();
|
---|
693 | rectl.yTop = wnd->getWindowHeight();
|
---|
694 | }
|
---|
695 |
|
---|
696 | //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
|
---|
697 | dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
|
---|
698 | wnd->SaveClipRegion(pHps->hrgnWin32Clip);
|
---|
699 | wnd->SaveVisRegion(pHps->hrgnWinVis);
|
---|
700 |
|
---|
701 | //clear visible and clip regions
|
---|
702 | pHps->hrgnWin32Clip = NULLHANDLE;
|
---|
703 | pHps->hrgnWinVis = NULLHANDLE;
|
---|
704 |
|
---|
705 | HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectl);
|
---|
706 | GdiSetVisRgn(pHps, hrgnVis);
|
---|
707 |
|
---|
708 | selectClientArea(wnd, pHps);
|
---|
709 |
|
---|
710 | if(bIcon) {
|
---|
711 | lComplexity = RGN_RECT;
|
---|
712 | }
|
---|
713 | else lComplexity = RGN_NULL;
|
---|
714 | }
|
---|
715 | else {
|
---|
716 | rectlClip.yBottom = rectlClip.xLeft = 0;
|
---|
717 | rectlClip.yTop = rectlClip.xRight = 1;
|
---|
718 |
|
---|
719 | //Query update region
|
---|
720 | HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectlClip);
|
---|
721 | WinQueryUpdateRegion(hwndClient, hrgnVis);
|
---|
722 | WinValidateRegion(hwndClient, hrgnVis, FALSE);
|
---|
723 |
|
---|
724 | dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnVis);
|
---|
725 |
|
---|
726 | #ifdef DEBUG
|
---|
727 | //Note: GpiQueryClipBox returns logical points
|
---|
728 | lComplexity = GpiQueryClipBox(pHps->hps, &rectlClip);
|
---|
729 | dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
|
---|
730 | #endif
|
---|
731 |
|
---|
732 | //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
|
---|
733 | dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
|
---|
734 | wnd->SaveClipRegion(pHps->hrgnWin32Clip);
|
---|
735 | wnd->SaveVisRegion(pHps->hrgnWinVis);
|
---|
736 |
|
---|
737 | //clear visible and clip regions
|
---|
738 | pHps->hrgnWin32Clip = NULLHANDLE;
|
---|
739 | pHps->hrgnWinVis = NULLHANDLE;
|
---|
740 |
|
---|
741 | //set clip region
|
---|
742 | lComplexity = GdiSetVisRgn(pHps, hrgnVis);
|
---|
743 |
|
---|
744 | if(lComplexity == NULLREGION_W) {
|
---|
745 | dprintf (("BeginPaint %x: EMPTY update rectangle (vis=%d/%d show=%d/%d", hWnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()), WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
|
---|
746 | }
|
---|
747 | else dprintf (("BeginPaint %x: (vis=%d/%d show=%d/%d)", hWnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()), WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
|
---|
748 |
|
---|
749 | selectClientArea(wnd, pHps);
|
---|
750 |
|
---|
751 | #ifdef DEBUG
|
---|
752 | //Note: GpiQueryClipBox returns logical points
|
---|
753 | GpiQueryClipBox(pHps->hps, &rectlClip);
|
---|
754 | dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
|
---|
755 | #endif
|
---|
756 | }
|
---|
757 |
|
---|
758 | if(hPS_ownDC == 0)
|
---|
759 | setMapMode (wnd, pHps, MM_TEXT_W);
|
---|
760 | else
|
---|
761 | setPageXForm(wnd, pHps);
|
---|
762 |
|
---|
763 | pHps->hdcType = TYPE_3;
|
---|
764 |
|
---|
765 | HideCaret(hwnd);
|
---|
766 | WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
|
---|
767 |
|
---|
768 | if((wnd->needsEraseBkgnd() || wnd->hasPMUpdateRegionChanged()) && lComplexity != RGN_NULL) {
|
---|
769 | wnd->setEraseBkgnd(FALSE);
|
---|
770 | wnd->SetPMUpdateRegionChanged(FALSE);
|
---|
771 | lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
|
---|
772 | }
|
---|
773 | else lpps->fErase = TRUE;
|
---|
774 |
|
---|
775 | lpps->hdc = (HDC)pHps->hps;
|
---|
776 |
|
---|
777 | if(lComplexity != RGN_NULL) {
|
---|
778 | long height = wnd->getClientHeight();
|
---|
779 | lpps->rcPaint.top = height - rectl.yTop;
|
---|
780 | lpps->rcPaint.left = rectl.xLeft;
|
---|
781 | lpps->rcPaint.bottom = height - rectl.yBottom;
|
---|
782 | lpps->rcPaint.right = rectl.xRight;
|
---|
783 | //BeginPaint must return logical points instead of device points.
|
---|
784 | //(not the same if e.g. app changes page viewport)
|
---|
785 | DPtoLP(lpps->hdc, (LPPOINT)&lpps->rcPaint, 2);
|
---|
786 | }
|
---|
787 | else {
|
---|
788 | lpps->rcPaint.bottom = lpps->rcPaint.top = 0;
|
---|
789 | lpps->rcPaint.right = lpps->rcPaint.left = 0;
|
---|
790 | }
|
---|
791 | RELEASE_WNDOBJ(wnd);
|
---|
792 |
|
---|
793 | SetLastError(0);
|
---|
794 | dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
|
---|
795 | return (HDC)pHps->hps;
|
---|
796 | }
|
---|
797 | //******************************************************************************
|
---|
798 | //******************************************************************************
|
---|
799 | BOOL WIN32API EndPaint (HWND hWnd, const PAINTSTRUCT_W *pPaint)
|
---|
800 | {
|
---|
801 | HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
|
---|
802 | pDCData pHps;
|
---|
803 |
|
---|
804 | dprintf (("USER32: EndPaint(%x)", hwnd));
|
---|
805 |
|
---|
806 | if (!pPaint || !pPaint->hdc )
|
---|
807 | return TRUE;
|
---|
808 |
|
---|
809 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
810 |
|
---|
811 | if (!wnd) goto exit;
|
---|
812 |
|
---|
813 | pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
|
---|
814 | if (pHps && (pHps->hdcType == TYPE_3))
|
---|
815 | {
|
---|
816 | //restore previous visible and clip regions
|
---|
817 | if(pHps->hrgnWinVis) {
|
---|
818 | GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
|
---|
819 | pHps->hrgnWinVis = NULLHANDLE;
|
---|
820 | }
|
---|
821 | if(pHps->hrgnWin32Clip) {
|
---|
822 | GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
|
---|
823 | pHps->hrgnWin32Clip = NULLHANDLE;
|
---|
824 | }
|
---|
825 |
|
---|
826 | GdiSetVisRgn(pHps, wnd->GetVisRegion());
|
---|
827 | GdiCombineVisRgnClipRgn(pHps, wnd->GetClipRegion(), RGN_AND_W);
|
---|
828 |
|
---|
829 | wnd->SaveClipRegion(0);
|
---|
830 | wnd->SaveVisRegion(0);
|
---|
831 |
|
---|
832 | pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
|
---|
833 | ReleaseDC(hwnd, pPaint->hdc);
|
---|
834 | }
|
---|
835 | else {
|
---|
836 | dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc));
|
---|
837 | }
|
---|
838 | wnd->setEraseBkgnd(TRUE);
|
---|
839 | ShowCaret(hwnd);
|
---|
840 | WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
|
---|
841 |
|
---|
842 | exit:
|
---|
843 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
844 | SetLastError(0);
|
---|
845 | return TRUE;
|
---|
846 | }
|
---|
847 | //******************************************************************************
|
---|
848 | //******************************************************************************
|
---|
849 | int WIN32API ReleaseDC (HWND hwnd, HDC hdc)
|
---|
850 | {
|
---|
851 | BOOL isOwnDC = FALSE;
|
---|
852 | int rc;
|
---|
853 |
|
---|
854 | HWND hwndDC = WindowFromDC(hdc);
|
---|
855 |
|
---|
856 | //hwndDC can be zero if the window has already been destroyed
|
---|
857 | if(hwndDC != hwnd) {
|
---|
858 | dprintf(("WARNING: ReleaseDC: wrong window handle specified %x -> %x", hwnd, hwndDC));
|
---|
859 | hwnd = hwndDC;
|
---|
860 | }
|
---|
861 |
|
---|
862 | if (hwnd)
|
---|
863 | {
|
---|
864 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
865 | if(wnd == NULL) {
|
---|
866 | dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
|
---|
867 | return 0;
|
---|
868 | }
|
---|
869 | isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
|
---|
870 | if(!isOwnDC)
|
---|
871 | {
|
---|
872 | pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
|
---|
873 | if(pHps && pHps->psType == MICRO_CACHED) {
|
---|
874 | removeClientArea(wnd, pHps);
|
---|
875 | if(pHps->hrgnWinVis) {
|
---|
876 | GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
|
---|
877 | pHps->hrgnWinVis = 0;
|
---|
878 | }
|
---|
879 | if(pHps->hrgnWin32Clip) {
|
---|
880 | GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
|
---|
881 | pHps->hrgnWin32Clip = 0;
|
---|
882 | }
|
---|
883 | }
|
---|
884 | else {
|
---|
885 | dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
|
---|
886 | DebugInt3();
|
---|
887 | }
|
---|
888 | }
|
---|
889 | else {
|
---|
890 | dprintf2(("ReleaseDC: CS_OWNDC, not released"));
|
---|
891 | }
|
---|
892 | if(!isOwnDC && !wnd->isDesktopWindow()) {
|
---|
893 | //remove from list of open DCs for this window
|
---|
894 | wnd->removeOpenDC(hdc);
|
---|
895 | }
|
---|
896 | RELEASE_WNDOBJ(wnd);
|
---|
897 | }
|
---|
898 |
|
---|
899 | STATS_ReleaseDC(hwnd, hdc);
|
---|
900 | if(isOwnDC) {
|
---|
901 | rc = TRUE;
|
---|
902 | }
|
---|
903 | else {
|
---|
904 | UnselectGDIObjects(hdc);
|
---|
905 | rc = O32_ReleaseDC (0, hdc);
|
---|
906 | }
|
---|
907 |
|
---|
908 | dprintf(("ReleaseDC %x %x", hwnd, hdc));
|
---|
909 | return (rc);
|
---|
910 | }
|
---|
911 | //******************************************************************************
|
---|
912 | // This implementation of GetDCEx supports:
|
---|
913 | //
|
---|
914 | // DCX_WINDOW
|
---|
915 | // DCX_CACHE
|
---|
916 | // DCX_EXCLUDERGN (complex regions allowed)
|
---|
917 | // DCX_INTERSECTRGN (complex regions allowed)
|
---|
918 | // DCX_USESTYLE
|
---|
919 | // DCX_CLIPSIBLINGS
|
---|
920 | // DCX_CLIPCHILDREN
|
---|
921 | // DCX_PARENTCLIP
|
---|
922 | //
|
---|
923 | // Not supported:
|
---|
924 | //
|
---|
925 | // DCX_NORESETATTRS_W
|
---|
926 | // DCX_INTERSECTUPDATE_W
|
---|
927 | // DCX_LOCKWINDOWUPDATE_W
|
---|
928 | // DCX_VALIDATE_W
|
---|
929 | // DCX_EXCLUDEUPDATE_W
|
---|
930 | //
|
---|
931 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
---|
932 | //******************************************************************************
|
---|
933 | HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
|
---|
934 | {
|
---|
935 | Win32BaseWindow *wnd = NULL;
|
---|
936 | HWND hWindow;
|
---|
937 | BOOL success;
|
---|
938 | pDCData pHps = NULL;
|
---|
939 | HPS hps = NULLHANDLE;
|
---|
940 | BOOL drawingAllowed = TRUE;
|
---|
941 | BOOL isWindowOwnDC;
|
---|
942 | BOOL creatingOwnDC = FALSE;
|
---|
943 | PS_Type psType;
|
---|
944 |
|
---|
945 | if(flags & (DCX_NORESETATTRS_W | DCX_INTERSECTUPDATE_W | DCX_LOCKWINDOWUPDATE_W | DCX_VALIDATE_W | DCX_EXCLUDEUPDATE_W)) {
|
---|
946 | dprintf(("ERROR: GetDCEx: unsupported flags %x!!", flags));
|
---|
947 | DebugInt3();
|
---|
948 | }
|
---|
949 |
|
---|
950 | if(hwnd == 0) {
|
---|
951 | dprintf(("error: GetDCEx window %x not found", hwnd));
|
---|
952 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
953 | return 0;
|
---|
954 | }
|
---|
955 |
|
---|
956 | if(hwnd)
|
---|
957 | {
|
---|
958 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
959 | if(wnd == NULL) {
|
---|
960 | dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
|
---|
961 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
962 | return 0;
|
---|
963 | }
|
---|
964 | if(flags & DCX_WINDOW_W) {
|
---|
965 | hWindow = wnd->getOS2FrameWindowHandle();
|
---|
966 | }
|
---|
967 | else hWindow = wnd->getOS2WindowHandle();
|
---|
968 | }
|
---|
969 |
|
---|
970 | isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
|
---|
971 | && !(flags & (DCX_CACHE_W|DCX_WINDOW_W)));
|
---|
972 |
|
---|
973 | if(isWindowOwnDC) //own dc always for client area
|
---|
974 | {
|
---|
975 | hps = wnd->getOwnDC();
|
---|
976 | if (hps)
|
---|
977 | {
|
---|
978 | pDCData pHps = (pDCData)GpiQueryDCData (hps);
|
---|
979 | if (!pHps)
|
---|
980 | goto error;
|
---|
981 |
|
---|
982 | selectClientArea(wnd, pHps);
|
---|
983 |
|
---|
984 | //TODO: Is this always necessary??
|
---|
985 | setPageXForm (wnd, pHps);
|
---|
986 | pHps->hdcType = TYPE_1;
|
---|
987 |
|
---|
988 | //TODO: intersect/exclude clip region?
|
---|
989 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
|
---|
990 |
|
---|
991 | RELEASE_WNDOBJ(wnd);
|
---|
992 |
|
---|
993 | STATS_GetDCEx(hwnd, hps, hrgn, flags);
|
---|
994 |
|
---|
995 | return (HDC)hps;
|
---|
996 | }
|
---|
997 | else creatingOwnDC = TRUE;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | if(isWindowOwnDC)
|
---|
1001 | {
|
---|
1002 | SIZEL sizel = {0,0};
|
---|
1003 | hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
|
---|
1004 | WinOpenWindowDC (hWindow),
|
---|
1005 | &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
|
---|
1006 | psType = MICRO;
|
---|
1007 | // default cp is OS/2 one: set to windows default (ODIN.INI)
|
---|
1008 | GpiSetCp(hps, GetDisplayCodepage());
|
---|
1009 | }
|
---|
1010 | else
|
---|
1011 | {
|
---|
1012 | if (hWindow == HWND_DESKTOP) {
|
---|
1013 | hps = WinGetScreenPS (hWindow);
|
---|
1014 | }
|
---|
1015 | else {
|
---|
1016 | int clipstyle = 0;
|
---|
1017 | int clipwnd = HWND_TOP;
|
---|
1018 | if(flags & (DCX_USESTYLE_W))
|
---|
1019 | {
|
---|
1020 | int style = wnd->getStyle();
|
---|
1021 | if(style & WS_CLIPCHILDREN_W) {
|
---|
1022 | clipstyle |= PSF_CLIPCHILDREN;
|
---|
1023 | }
|
---|
1024 | if(style & WS_CLIPSIBLINGS_W) {
|
---|
1025 | clipstyle |= PSF_CLIPSIBLINGS;
|
---|
1026 | }
|
---|
1027 | if(wnd->fHasParentDC()) {
|
---|
1028 | clipstyle |= PSF_PARENTCLIP;
|
---|
1029 | }
|
---|
1030 | }
|
---|
1031 | if(flags & DCX_CLIPSIBLINGS_W) {
|
---|
1032 | clipstyle |= PSF_CLIPSIBLINGS;
|
---|
1033 | }
|
---|
1034 | if(flags & DCX_CLIPCHILDREN_W) {
|
---|
1035 | clipstyle |= PSF_CLIPCHILDREN;
|
---|
1036 | }
|
---|
1037 | if(flags & DCX_PARENTCLIP_W) {
|
---|
1038 | clipstyle |= PSF_PARENTCLIP;
|
---|
1039 | }
|
---|
1040 | //Always call WinGetClipPS; WinGetPS takes window & class style
|
---|
1041 | //into account
|
---|
1042 | // if(clipstyle || !(flags & DCX_DEFAULTCLIP_W)) {
|
---|
1043 | dprintf2(("WinGetClipPS style %x", clipstyle));
|
---|
1044 | hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
|
---|
1045 | // }
|
---|
1046 | // else hps = WinGetPS (hWindow);
|
---|
1047 |
|
---|
1048 | // default cp is OS/2 one: set to windows default (ODIN.INI)
|
---|
1049 | GpiSetCp(hps, GetDisplayCodepage());
|
---|
1050 | }
|
---|
1051 | psType = MICRO_CACHED;
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | if (!hps)
|
---|
1055 | goto error;
|
---|
1056 |
|
---|
1057 | HPSToHDC (hWindow, hps, NULL, NULL);
|
---|
1058 | pHps = (pDCData)GpiQueryDCData (hps);
|
---|
1059 |
|
---|
1060 | if(flags & DCX_WINDOW_W) {
|
---|
1061 | removeClientArea(wnd, pHps);
|
---|
1062 | }
|
---|
1063 | else selectClientArea(wnd, pHps);
|
---|
1064 |
|
---|
1065 | setMapMode(wnd, pHps, MM_TEXT_W);
|
---|
1066 |
|
---|
1067 | if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
|
---|
1068 | {
|
---|
1069 | ULONG BytesNeeded;
|
---|
1070 | PRGNDATA RgnData;
|
---|
1071 | PRECT pr;
|
---|
1072 | int i;
|
---|
1073 | RECTL rectl;
|
---|
1074 |
|
---|
1075 | if (!hrgn)
|
---|
1076 | goto error;
|
---|
1077 |
|
---|
1078 | success = TRUE;
|
---|
1079 | if (flags & DCX_EXCLUDERGN_W)
|
---|
1080 | {//exclude specified region from visible region
|
---|
1081 | success = (GdiCombineVisRgn(pHps, hrgn, RGN_DIFF_W) != ERROR_W);
|
---|
1082 | }
|
---|
1083 | else //DCX_INTERSECTRGN_W
|
---|
1084 | {//intersect visible region with specified region
|
---|
1085 | success = (GdiCombineVisRgn(pHps, hrgn, RGN_AND_W) != ERROR_W);
|
---|
1086 | }
|
---|
1087 | if (!success)
|
---|
1088 | goto error;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | if (creatingOwnDC)
|
---|
1092 | wnd->setOwnDC ((HDC)hps);
|
---|
1093 |
|
---|
1094 | pHps->psType = psType;
|
---|
1095 | pHps->hdcType = TYPE_1;
|
---|
1096 | //TODO: WM_SETREDRAW affects drawingAllowed flag!!
|
---|
1097 | GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
|
---|
1098 |
|
---|
1099 | dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
|
---|
1100 |
|
---|
1101 | //add to list of open DCs for this window
|
---|
1102 | if(wnd->isDesktopWindow() == FALSE) {//not relevant for the desktop window
|
---|
1103 | wnd->addOpenDC((HDC)pHps->hps);
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | RELEASE_WNDOBJ(wnd);
|
---|
1107 |
|
---|
1108 | STATS_GetDCEx(hwnd, pHps->hps, hrgn, flags);
|
---|
1109 | return (HDC)pHps->hps;
|
---|
1110 |
|
---|
1111 | error:
|
---|
1112 | /* Something went wrong; clean up
|
---|
1113 | */
|
---|
1114 | dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));
|
---|
1115 | DebugInt3();
|
---|
1116 | if (pHps)
|
---|
1117 | {
|
---|
1118 | if (pHps->hps)
|
---|
1119 | {
|
---|
1120 | if(pHps->psType == MICRO_CACHED)
|
---|
1121 | WinReleasePS(pHps->hps);
|
---|
1122 | else
|
---|
1123 | GpiDestroyPS(pHps->hps);
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | if (pHps->hdc) DevCloseDC(pHps->hdc);
|
---|
1127 | if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
|
---|
1128 |
|
---|
1129 | O32_DeleteObject (pHps->nullBitmapHandle);
|
---|
1130 | }
|
---|
1131 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
1132 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1133 | return NULL;
|
---|
1134 | }
|
---|
1135 | //******************************************************************************
|
---|
1136 | //******************************************************************************
|
---|
1137 | HDC WIN32API GetDC (HWND hwnd)
|
---|
1138 | {
|
---|
1139 | if(!hwnd)
|
---|
1140 | return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
|
---|
1141 |
|
---|
1142 | return GetDCEx (hwnd, NULL, DCX_USESTYLE_W);
|
---|
1143 | }
|
---|
1144 | //******************************************************************************
|
---|
1145 | //******************************************************************************
|
---|
1146 | HDC WIN32API GetWindowDC (HWND hwnd)
|
---|
1147 | {
|
---|
1148 | if (!hwnd) hwnd = GetDesktopWindow();
|
---|
1149 | return GetDCEx (hwnd, NULL, DCX_WINDOW_W | DCX_USESTYLE_W);
|
---|
1150 | }
|
---|
1151 | //******************************************************************************
|
---|
1152 | //Helper for RedrawWindow (RDW_ALLCHILDREN_W)
|
---|
1153 | //******************************************************************************
|
---|
1154 | LRESULT WIN32API RedrawChildEnumProc(HWND hwnd, LPARAM lParam)
|
---|
1155 | {
|
---|
1156 | RedrawWindow(hwnd, NULL, 0, lParam);
|
---|
1157 | return TRUE;
|
---|
1158 | }
|
---|
1159 | //******************************************************************************
|
---|
1160 | // This implementation of RedrawWindow supports
|
---|
1161 | // RDW_ERASE
|
---|
1162 | // RDW_NOERASE
|
---|
1163 | // RDW_INTERNALPAINT
|
---|
1164 | // RDW_NOINTERNALPAINT
|
---|
1165 | // RDW_INVALIDATE
|
---|
1166 | // RDW_VALIDATE
|
---|
1167 | // RDW_ERASENOW
|
---|
1168 | // RDW_UPDATENOW
|
---|
1169 | // RDW_FRAME
|
---|
1170 | //
|
---|
1171 | //TODO: Works ok for RDW_FRAME??
|
---|
1172 | // SDK docs say RDW_FRAME is only valid for RDW_INVALIDATE...
|
---|
1173 | //******************************************************************************
|
---|
1174 | BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
|
---|
1175 | {
|
---|
1176 | Win32BaseWindow *wnd;
|
---|
1177 |
|
---|
1178 | if(pRect) {
|
---|
1179 | dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
|
---|
1180 | }
|
---|
1181 | else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
|
---|
1182 |
|
---|
1183 | if (hwnd == NULLHANDLE)
|
---|
1184 | {
|
---|
1185 | hwnd = HWND_DESKTOP;
|
---|
1186 | wnd = Win32BaseWindow::GetWindowFromOS2Handle(OSLIB_HWND_DESKTOP);
|
---|
1187 |
|
---|
1188 | if (!wnd)
|
---|
1189 | {
|
---|
1190 | dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n",
|
---|
1191 | hwnd));
|
---|
1192 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1193 | return FALSE;
|
---|
1194 | }
|
---|
1195 | }
|
---|
1196 | else
|
---|
1197 | {
|
---|
1198 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1199 |
|
---|
1200 | if (!wnd)
|
---|
1201 | {
|
---|
1202 | dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n",
|
---|
1203 | hwnd));
|
---|
1204 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1205 | return FALSE;
|
---|
1206 | }
|
---|
1207 | if(redraw & RDW_FRAME_W) {
|
---|
1208 | hwnd = wnd->getOS2FrameWindowHandle();
|
---|
1209 | }
|
---|
1210 | else hwnd = wnd->getOS2WindowHandle();
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 | //check if the application previously didn't handle a WM_PAINT msg properly
|
---|
1214 | wnd->checkForDirtyUpdateRegion();
|
---|
1215 |
|
---|
1216 | BOOL IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE;
|
---|
1217 | BOOL success = TRUE;
|
---|
1218 | HPS hpsTemp = NULLHANDLE;
|
---|
1219 | HRGN hrgnTemp = NULLHANDLE;
|
---|
1220 | RECTL rectl;
|
---|
1221 |
|
---|
1222 | if (hrgn)
|
---|
1223 | {
|
---|
1224 | ULONG BytesNeeded;
|
---|
1225 | PRGNDATA RgnData;
|
---|
1226 | PRECTL pr;
|
---|
1227 | int i;
|
---|
1228 | LONG height;
|
---|
1229 |
|
---|
1230 | if(wnd) {
|
---|
1231 | height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight();
|
---|
1232 | }
|
---|
1233 | else height = OSLibQueryScreenHeight();
|
---|
1234 |
|
---|
1235 | if (!hrgn)
|
---|
1236 | goto error;
|
---|
1237 |
|
---|
1238 | BytesNeeded = GetRegionData (hrgn, 0, NULL);
|
---|
1239 | RgnData = (PRGNDATA)_alloca (BytesNeeded);
|
---|
1240 | if (RgnData == NULL)
|
---|
1241 | goto error;
|
---|
1242 | GetRegionData (hrgn, BytesNeeded, RgnData);
|
---|
1243 |
|
---|
1244 | pr = (PRECTL)(RgnData->Buffer);
|
---|
1245 | for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
|
---|
1246 | LONG temp = pr->yTop;
|
---|
1247 | pr->yTop = height - pr->yBottom;
|
---|
1248 | pr->yBottom = height - temp;
|
---|
1249 | dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | hpsTemp = WinGetScreenPS (HWND_DESKTOP);
|
---|
1253 | hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
|
---|
1254 | if (!hrgnTemp) goto error;
|
---|
1255 | }
|
---|
1256 | else if (pRect)
|
---|
1257 | {
|
---|
1258 | if(wnd) {
|
---|
1259 | if(redraw & RDW_FRAME_W) {
|
---|
1260 | mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
|
---|
1261 | }
|
---|
1262 | else mapWin32ToOS2Rect(wnd->getClientHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
|
---|
1263 | }
|
---|
1264 | else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 | if (redraw & RDW_INVALIDATE_W)
|
---|
1268 | {
|
---|
1269 | //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs
|
---|
1270 | if (redraw & RDW_ERASE_W) {
|
---|
1271 | wnd->setEraseBkgnd(TRUE);
|
---|
1272 | }
|
---|
1273 | else
|
---|
1274 | //Don't clear erase background flag if the window is
|
---|
1275 | //already (partly) invalidated
|
---|
1276 | if (!WinQueryUpdateRect (hwnd, NULL)) {
|
---|
1277 | dprintf(("RDW_INVALIDATE: no update rectangle, disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
|
---|
1278 | wnd->setEraseBkgnd(FALSE);
|
---|
1279 | }
|
---|
1280 |
|
---|
1281 | if (!pRect && !hrgn)
|
---|
1282 | success = WinInvalidateRect (hwnd, NULL, IncludeChildren);
|
---|
1283 | else
|
---|
1284 | if (hrgn) {
|
---|
1285 | success = WinInvalidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
---|
1286 | if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) {
|
---|
1287 | dprintf(("WARNING: WinQueryUpdateRect %x region %x returned false even though we just invalidated part of a window!!!", hwnd, hrgnTemp));
|
---|
1288 | success = success = WinInvalidateRegion (hwnd, hrgnTemp, FALSE);
|
---|
1289 | }
|
---|
1290 | }
|
---|
1291 | else {
|
---|
1292 | dprintf2(("WinInvalidateRect (%d,%d)(%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
---|
1293 | success = WinInvalidateRect (hwnd, &rectl, IncludeChildren);
|
---|
1294 | //SvL: If all children are included, then WinInvalidateRect is called
|
---|
1295 | // with fIncludeChildren=1 -> rect of hwnd isn't invalidated if child(ren)
|
---|
1296 | // overlap(s) the specified rectangle completely (EVEN if window doesn't
|
---|
1297 | // have WS_CLIPCHILREN!)
|
---|
1298 | // -> example: XWing vs Tie Fighter install window
|
---|
1299 | // WinInvalidateRect with fIncludeChildren=0 invalidates both the parent
|
---|
1300 | // and child windows
|
---|
1301 | //SvL: Can't always set fIncludeChildren to FALSE or else some controls in
|
---|
1302 | // the RealPlayer setup application aren't redrawn when invalidating
|
---|
1303 | // their parent
|
---|
1304 | // SO: Check if IncludeChildren is set and part of the window is invalid
|
---|
1305 | // If not -> call WinInvalidateRect with IncludeChildren=0 to force
|
---|
1306 | // the window rectangle to be invalidated
|
---|
1307 | //
|
---|
1308 | if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) {
|
---|
1309 | dprintf(("WARNING: WinQueryUpdateRect %x (%d,%d)(%d,%d) returned false even though we just invalidated part of a window!!!", hwnd, rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
---|
1310 | success = WinInvalidateRect (hwnd, &rectl, FALSE);
|
---|
1311 | }
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | if (!success) goto error;
|
---|
1315 | }
|
---|
1316 | else if (redraw & RDW_VALIDATE_W)
|
---|
1317 | {
|
---|
1318 | if (redraw & RDW_NOERASE_W) {
|
---|
1319 | dprintf(("RDW_NOERASE: disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
|
---|
1320 | wnd->setEraseBkgnd(FALSE);
|
---|
1321 | }
|
---|
1322 | if (WinQueryUpdateRect (hwnd, NULL))
|
---|
1323 | {
|
---|
1324 | if(!pRect && !hrgn) {
|
---|
1325 | success = WinValidateRect (hwnd, NULL, IncludeChildren);
|
---|
1326 | }
|
---|
1327 | else
|
---|
1328 | if(hrgn) {
|
---|
1329 | success = WinValidateRegion (hwnd, hrgnTemp, IncludeChildren);
|
---|
1330 | }
|
---|
1331 | else {
|
---|
1332 | success = WinValidateRect (hwnd, &rectl, IncludeChildren);
|
---|
1333 | }
|
---|
1334 | if(!success) goto error;
|
---|
1335 | }
|
---|
1336 | }
|
---|
1337 |
|
---|
1338 | if(WinQueryUpdateRect(hwnd, &rectl))
|
---|
1339 | {
|
---|
1340 | dprintf2(("Update region (%d,%d)(%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
---|
1341 | //TODO: Does this work if RDW_ALLCHILDREN is set??
|
---|
1342 | if(redraw & RDW_UPDATENOW_W)
|
---|
1343 | {
|
---|
1344 | dprintf(("RDW_UPDATENOW -> UpdateWindow"));
|
---|
1345 | UpdateWindow(wnd->getWindowHandle());
|
---|
1346 | }
|
---|
1347 | else
|
---|
1348 | // if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))
|
---|
1349 | if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd())
|
---|
1350 | wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
|
---|
1351 | // if(redraw & RDW_ALLCHILDREN_W) {
|
---|
1352 | // EnumChildWindows(wnd->getWindowHandle(), RedrawChildEnumProc, redraw);
|
---|
1353 | // }
|
---|
1354 | }
|
---|
1355 | else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
|
---|
1356 | {
|
---|
1357 | dprintf(("Manual redraw"));
|
---|
1358 | if(redraw & RDW_UPDATENOW_W) {
|
---|
1359 | wnd->MsgPaint(0, FALSE);
|
---|
1360 | }
|
---|
1361 | else PostMessageA(hwnd, WINWM_PAINT, 0, 0);
|
---|
1362 | }
|
---|
1363 |
|
---|
1364 | error:
|
---|
1365 | /* clean up */
|
---|
1366 | if (hrgnTemp)
|
---|
1367 | GpiDestroyRegion (hpsTemp, hrgnTemp);
|
---|
1368 |
|
---|
1369 | if (hpsTemp)
|
---|
1370 | WinReleasePS (hpsTemp);
|
---|
1371 |
|
---|
1372 | if (!success) {
|
---|
1373 | dprintf(("RedrawWindow failure!"));
|
---|
1374 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
---|
1375 | }
|
---|
1376 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
1377 | return (success);
|
---|
1378 | }
|
---|
1379 | //******************************************************************************
|
---|
1380 | //******************************************************************************
|
---|
1381 | BOOL WIN32API UpdateWindow (HWND hwnd)
|
---|
1382 | {
|
---|
1383 | Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1384 | RECTL rectl;
|
---|
1385 | BOOL rc;
|
---|
1386 |
|
---|
1387 | if(!wnd) {
|
---|
1388 | dprintf (("ERROR: User32: UpdateWindow INVALID hwnd %x", hwnd));
|
---|
1389 | SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
|
---|
1390 | return FALSE;
|
---|
1391 | }
|
---|
1392 |
|
---|
1393 | //check if the application previously didn't handle a WM_PAINT msg properly
|
---|
1394 | wnd->checkForDirtyUpdateRegion();
|
---|
1395 |
|
---|
1396 | #ifdef DEBUG
|
---|
1397 | if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), &rectl))
|
---|
1398 | {
|
---|
1399 | RECT rectUpdate;
|
---|
1400 | mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, &rectUpdate);
|
---|
1401 |
|
---|
1402 | dprintf (("User32: UpdateWindow hwnd %x: update rectangle (%d,%d)(%d,%d)", hwnd, rectUpdate.left, rectUpdate.top, rectUpdate.right, rectUpdate.bottom));
|
---|
1403 | }
|
---|
1404 | else dprintf (("User32: UpdateWindow hwnd %x; EMPTY update rectangle (vis=%d/%d, show=%d/%d, vis parent=%d)", hwnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()), WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()), IsWindowVisible(GetParent(hwnd))));
|
---|
1405 | #endif
|
---|
1406 | //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
|
---|
1407 | // Breaks vpbuddy
|
---|
1408 | //rc = RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
|
---|
1409 | // -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window
|
---|
1410 | // handler; possibly bypassing queued WM_PAINT messages for parent window(s)
|
---|
1411 | // -> out of sync painting (i.e. parent paints over child)
|
---|
1412 |
|
---|
1413 | // if(!WinIsWindowShowing(wnd->getOS2FrameWindowHandle()) || !WinIsWindowShowing(wnd->getOS2WindowHandle())) {
|
---|
1414 | // dprintf(("UpdateWindow: window not showing %d/%d", WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()) ));
|
---|
1415 | // RELEASE_WNDOBJ(wnd);
|
---|
1416 | // return FALSE;
|
---|
1417 | // }
|
---|
1418 | //Must use frame window here. If the frame window has a valid update region and we call
|
---|
1419 | //WinUpdateWindow for the client window, then no WM_PAINT messages will be sent.
|
---|
1420 | rc = WinUpdateWindow(wnd->getOS2FrameWindowHandle());
|
---|
1421 | #ifdef DEBUG
|
---|
1422 | if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), NULL))
|
---|
1423 | {
|
---|
1424 | //if parent has valid update region then WinUpdateWindow will still fail..
|
---|
1425 | //might be harmless and happen even in windows
|
---|
1426 | dprintf (("ERROR: User32: UpdateWindow didn't send WM_PAINT messages!!"));
|
---|
1427 | }
|
---|
1428 | #endif
|
---|
1429 | RELEASE_WNDOBJ(wnd);
|
---|
1430 | return rc;
|
---|
1431 | }
|
---|
1432 | //******************************************************************************
|
---|
1433 | //******************************************************************************
|
---|
1434 | BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
|
---|
1435 | {
|
---|
1436 | if(lprc) {
|
---|
1437 | dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
|
---|
1438 | }
|
---|
1439 | else dprintf(("USER32: ValidateRect %x", hwnd));
|
---|
1440 |
|
---|
1441 | return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
---|
1442 | }
|
---|
1443 | //******************************************************************************
|
---|
1444 | //******************************************************************************
|
---|
1445 | BOOL WIN32API ValidateRgn( HWND hwnd, HRGN hrgn)
|
---|
1446 | {
|
---|
1447 | dprintf(("USER32: ValidateRgn %x %x", hwnd, hrgn));
|
---|
1448 | return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
|
---|
1449 | }
|
---|
1450 | //******************************************************************************
|
---|
1451 | //******************************************************************************
|
---|
1452 | BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase)
|
---|
1453 | {
|
---|
1454 | BOOL result;
|
---|
1455 |
|
---|
1456 | if(pRect) {
|
---|
1457 | dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase));
|
---|
1458 | }
|
---|
1459 | else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
|
---|
1460 | #if 1
|
---|
1461 | result = RedrawWindow (hwnd, pRect, NULLHANDLE,
|
---|
1462 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1463 | (erase ? RDW_ERASE_W : 0) |
|
---|
1464 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1465 | #else
|
---|
1466 | result = RedrawWindow (hwnd, pRect, NULLHANDLE,
|
---|
1467 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1468 | (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
|
---|
1469 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1470 | #endif
|
---|
1471 | return (result);
|
---|
1472 | }
|
---|
1473 | //******************************************************************************
|
---|
1474 | //******************************************************************************
|
---|
1475 | BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
|
---|
1476 | {
|
---|
1477 | BOOL result;
|
---|
1478 |
|
---|
1479 | dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
|
---|
1480 | #if 1
|
---|
1481 | result = RedrawWindow (hwnd, NULL, hrgn,
|
---|
1482 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1483 | (erase ? RDW_ERASE_W : 0) |
|
---|
1484 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1485 | #else
|
---|
1486 | result = RedrawWindow (hwnd, NULL, hrgn,
|
---|
1487 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1488 | (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
|
---|
1489 | (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
|
---|
1490 | #endif
|
---|
1491 | return (result);
|
---|
1492 | }
|
---|
1493 | //******************************************************************************
|
---|
1494 | //TODO: Change for client rectangle!!!!!
|
---|
1495 | //******************************************************************************
|
---|
1496 | BOOL setPMRgnIntoWinRgn (HPS hps, HRGN hrgnPM, HRGN hrgnWin, LONG height)
|
---|
1497 | {
|
---|
1498 | BOOL rc;
|
---|
1499 | RGNRECT rgnRect;
|
---|
1500 | rgnRect.ircStart = 1;
|
---|
1501 | rgnRect.crc = 0;
|
---|
1502 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
|
---|
1503 |
|
---|
1504 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, NULL);
|
---|
1505 |
|
---|
1506 | if (rc && (rgnRect.crcReturned > 0))
|
---|
1507 | {
|
---|
1508 | PRECTL Rcls = new RECTL[rgnRect.crcReturned];
|
---|
1509 | PRECTL pRcl = Rcls;
|
---|
1510 |
|
---|
1511 | if (Rcls != NULL)
|
---|
1512 | {
|
---|
1513 | rgnRect.crc = rgnRect.crcReturned;
|
---|
1514 | rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
|
---|
1515 |
|
---|
1516 | rc = SetRectRgn(hrgnWin, pRcl->xLeft, height - pRcl->yTop,
|
---|
1517 | pRcl->xRight, height - pRcl->yBottom);
|
---|
1518 |
|
---|
1519 | if (rgnRect.crcReturned > 1)
|
---|
1520 | {
|
---|
1521 | int i;
|
---|
1522 | HRGN temp;
|
---|
1523 | temp = CreateRectRgn (0, 0, 1, 1);
|
---|
1524 |
|
---|
1525 | for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
|
---|
1526 | {
|
---|
1527 | rc = SetRectRgn (temp, pRcl->xLeft, height - pRcl->yTop,
|
---|
1528 | pRcl->xRight, height - pRcl->yBottom);
|
---|
1529 | rc &= CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
|
---|
1530 | }
|
---|
1531 | DeleteObject (temp);
|
---|
1532 | }
|
---|
1533 | delete[] Rcls;
|
---|
1534 | }
|
---|
1535 | else
|
---|
1536 | {
|
---|
1537 | rc = FALSE;
|
---|
1538 | }
|
---|
1539 | }
|
---|
1540 | else
|
---|
1541 | {
|
---|
1542 | rc = SetRectRgn (hrgnWin, 0, 0, 0, 0);
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | return (rc);
|
---|
1546 | }
|
---|
1547 | //******************************************************************************
|
---|
1548 | //Using WinScrollWindow to scroll child windows is better (smoother).
|
---|
1549 | //******************************************************************************
|
---|
1550 | INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
|
---|
1551 | HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
|
---|
1552 | {
|
---|
1553 | Win32BaseWindow *window;
|
---|
1554 | APIRET rc;
|
---|
1555 | RECTL scrollRect;
|
---|
1556 | RECTL clipRect;
|
---|
1557 | PRECTL pScrollOS2 = NULL;
|
---|
1558 | PRECTL pClipOS2 = NULL;
|
---|
1559 | ULONG scrollFlagsOS2 = 0;
|
---|
1560 | int orgdy = dy;
|
---|
1561 | int regionType = ERROR_W;
|
---|
1562 |
|
---|
1563 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1564 | if(!window) {
|
---|
1565 | dprintf(("ScrollWindowEx, window %x not found", hwnd));
|
---|
1566 | return 0;
|
---|
1567 | }
|
---|
1568 |
|
---|
1569 | dprintf(("ScrollWindowEx %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
---|
1570 |
|
---|
1571 | dy = revertDy (window, dy);
|
---|
1572 |
|
---|
1573 | if (scrollFlag & SW_INVALIDATE_W) scrollFlagsOS2 |= SW_INVALIDATERGN;
|
---|
1574 | if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlagsOS2 |= SW_SCROLLCHILDREN;
|
---|
1575 |
|
---|
1576 | if(pScroll) {
|
---|
1577 | mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pScroll, (PRECTLOS2)&scrollRect);
|
---|
1578 | pScrollOS2 = &scrollRect;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | if(pClip) {
|
---|
1582 | mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pClip, (PRECTLOS2)&clipRect);
|
---|
1583 | pClipOS2 = &clipRect;
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | RECTL rectlUpdate;
|
---|
1587 | HRGN hrgn = NULLHANDLE;
|
---|
1588 | HPS hpsScreen = 0;
|
---|
1589 |
|
---|
1590 | if(hrgnUpdate) {
|
---|
1591 | RECTL rectl = { 1, 1, 2, 2 };
|
---|
1592 |
|
---|
1593 | hpsScreen = WinGetScreenPS (HWND_DESKTOP);
|
---|
1594 | hrgn = GpiCreateRegion(hpsScreen, 1, &rectl);
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | if (scrollFlag & SW_SMOOTHSCROLL_W)
|
---|
1598 | {
|
---|
1599 | INT time = (scrollFlag >> 16) & 0xFFFF;
|
---|
1600 |
|
---|
1601 | //CB: todo, scroll in several steps
|
---|
1602 | // is time in ms? time <-> iteration count?
|
---|
1603 | }
|
---|
1604 |
|
---|
1605 | LONG lComplexity = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
|
---|
1606 | pScrollOS2, pClipOS2,
|
---|
1607 | hrgn, &rectlUpdate, scrollFlagsOS2);
|
---|
1608 | if (lComplexity == RGN_ERROR)
|
---|
1609 | {
|
---|
1610 | goto fail;
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | //Notify children that they have moved (according to the SDK docs,
|
---|
1614 | //they only receive a WM_MOVE message)
|
---|
1615 | //(PM only does this for windows with CS_MOVENOTIFY class)
|
---|
1616 | //TODO: Verify this (no WM_WINDOWPOSCHANGING/ED?)
|
---|
1617 | if (scrollFlag & SW_SCROLLCHILDREN_W)
|
---|
1618 | {
|
---|
1619 | HWND hwndChild;
|
---|
1620 | RECT rectChild, rc;
|
---|
1621 |
|
---|
1622 | dprintf(("ScrollWindowEx: Scroll child windows"));
|
---|
1623 | GetClientRect(hwnd, &rc);
|
---|
1624 | if (pScroll) IntersectRect(&rc, &rc, pScroll);
|
---|
1625 |
|
---|
1626 | hwndChild = GetWindow(hwnd, GW_CHILD_W);
|
---|
1627 |
|
---|
1628 | while(hwndChild)
|
---|
1629 | {
|
---|
1630 | Win32BaseWindow *child;
|
---|
1631 |
|
---|
1632 | child = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
---|
1633 | if(!child) {
|
---|
1634 | dprintf(("ERROR: ScrollWindowEx, child %x not found", hwnd));
|
---|
1635 | goto fail;
|
---|
1636 | }
|
---|
1637 | rectChild = *child->getWindowRect();
|
---|
1638 | if(!pScroll || IntersectRect(&rectChild, &rectChild, &rc))
|
---|
1639 | {
|
---|
1640 | dprintf(("ScrollWindowEx: Scroll child window %x", hwndChild));
|
---|
1641 | child->ScrollWindow(dx, orgdy);
|
---|
1642 | }
|
---|
1643 | RELEASE_WNDOBJ(child);
|
---|
1644 | hwndChild = GetWindow(hwndChild, GW_HWNDNEXT_W);
|
---|
1645 | }
|
---|
1646 | dprintf(("***ScrollWindowEx: Scroll child windows DONE"));
|
---|
1647 | }
|
---|
1648 |
|
---|
1649 | RECT winRectUpdate;
|
---|
1650 |
|
---|
1651 | mapOS2ToWin32Rect(window->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
|
---|
1652 |
|
---|
1653 | if (pRectUpdate)
|
---|
1654 | *pRectUpdate = winRectUpdate;
|
---|
1655 |
|
---|
1656 | if (hrgnUpdate) {
|
---|
1657 | rc = setPMRgnIntoWinRgn(hpsScreen, hrgn, hrgnUpdate, window->getClientHeight());
|
---|
1658 | GpiDestroyRegion(hpsScreen, hrgn);
|
---|
1659 | WinReleasePS(hpsScreen);
|
---|
1660 | }
|
---|
1661 |
|
---|
1662 | #if 0
|
---|
1663 | //SvL: WinScrollWindow already invalidates the area; no need to do it again
|
---|
1664 | //(call to invalidateRect was wrong; has to include erase flag)
|
---|
1665 | if ((scrollFlag & SW_INVALIDATE_W) &&
|
---|
1666 | ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
|
---|
1667 | {
|
---|
1668 | rc = RedrawWindow (hwnd, &winRectUpdate, NULLHANDLE,
|
---|
1669 | RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
|
---|
1670 | ((scrollFlag & SW_ERASE_W) ? RDW_ERASE_W : 0) |
|
---|
1671 | RDW_UPDATENOW_W);
|
---|
1672 |
|
---|
1673 | // rc = InvalidateRect (hwnd, &winRectUpdate, (scrollFlag & SW_ERASE_W) ? 1 : 0);
|
---|
1674 | if (rc == FALSE)
|
---|
1675 | {
|
---|
1676 | RELEASE_WNDOBJ(window);
|
---|
1677 | return (0);
|
---|
1678 | }
|
---|
1679 | }
|
---|
1680 | #endif
|
---|
1681 |
|
---|
1682 | switch (lComplexity)
|
---|
1683 | {
|
---|
1684 | case RGN_NULL:
|
---|
1685 | regionType = NULLREGION_W;
|
---|
1686 | break;
|
---|
1687 | case RGN_RECT:
|
---|
1688 | regionType = SIMPLEREGION_W;
|
---|
1689 | break;
|
---|
1690 | case RGN_COMPLEX:
|
---|
1691 | regionType = COMPLEXREGION_W;
|
---|
1692 | break;
|
---|
1693 | default:
|
---|
1694 | regionType = ERROR_W;
|
---|
1695 | break;
|
---|
1696 | }
|
---|
1697 |
|
---|
1698 | RELEASE_WNDOBJ(window);
|
---|
1699 | return (regionType);
|
---|
1700 |
|
---|
1701 | fail:
|
---|
1702 | if(hrgn) GpiDestroyRegion(hpsScreen, hrgn);
|
---|
1703 | if(hpsScreen) WinReleasePS(hpsScreen);
|
---|
1704 | RELEASE_WNDOBJ(window);
|
---|
1705 | return ERROR_W;
|
---|
1706 | }
|
---|
1707 | //******************************************************************************
|
---|
1708 | //******************************************************************************
|
---|
1709 | BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
|
---|
1710 | {
|
---|
1711 | dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
|
---|
1712 | return (ERROR_W != ScrollWindowEx(hwnd, dx, dy, pScroll, pClip, 0, NULL,
|
---|
1713 | (pScroll ? 0 : SW_SCROLLCHILDREN_W) |
|
---|
1714 | SW_INVALIDATE_W ));
|
---|
1715 | }
|
---|
1716 | //******************************************************************************
|
---|
1717 | //******************************************************************************
|
---|
1718 | HWND WIN32API WindowFromDC(HDC hdc)
|
---|
1719 | {
|
---|
1720 | pDCData pHps = (pDCData)GpiQueryDCData( (HPS)hdc );
|
---|
1721 |
|
---|
1722 | dprintf2(("USER32: WindowFromDC %x", hdc));
|
---|
1723 | if ( pHps )
|
---|
1724 | return OS2ToWin32Handle(pHps->hwnd);
|
---|
1725 | else
|
---|
1726 | return 0;
|
---|
1727 | }
|
---|
1728 | //******************************************************************************
|
---|
1729 | //******************************************************************************
|
---|
1730 |
|
---|