source: trunk/src/user32/dc.cpp@ 21459

Last change on this file since 21459 was 21459, checked in by ydario, 15 years ago

Allow export by name of appearance control, so Flash can change look&feel.

File size: 57.1 KB
Line 
1/* $Id: dc.cpp,v 1.128 2004-03-18 15:38:41 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
71const XFORM_W XFORMIdentity = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
72const MATRIXLF matrixlfIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0};
73
74BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps);
75BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev);
76LONG 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
82void 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//******************************************************************************
100void 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//******************************************************************************
124void 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//******************************************************************************
134int 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//******************************************************************************
214BOOL 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//******************************************************************************
328BOOL 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//******************************************************************************
389VOID removeClientArea(Win32BaseWindow *window, pDCData pHps)
390{
391 pHps->isClient = FALSE;
392 pHps->isClientArea = FALSE;
393}
394//******************************************************************************
395//******************************************************************************
396void selectClientArea(Win32BaseWindow *window, pDCData pHps)
397{
398 pHps->isClient = TRUE;
399 pHps->isClientArea = TRUE;
400}
401//******************************************************************************
402//******************************************************************************
403void 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//******************************************************************************
412LONG 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//******************************************************************************
446BOOL 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//******************************************************************************
460BOOL 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//******************************************************************************
474VOID 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//******************************************************************************
489VOID 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//******************************************************************************
504VOID 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//******************************************************************************
520LONG 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//******************************************************************************
538int 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//******************************************************************************
552BOOL 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//******************************************************************************
570INT 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//******************************************************************************
590HDC 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//******************************************************************************
621HDC 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 dprintf (("USER32: BeginPaint(%x)", hwnd));
634
635 if(lpps == NULL) {
636 //BeginPaint does NOT change last error in this case
637 //(verified in NT4, SP6)
638 dprintf (("USER32: BeginPaint %x NULL PAINTSTRUCT pointer", hWnd));
639 return 0;
640 }
641 memset(lpps, 0, sizeof(*lpps));
642
643 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
644 if(!wnd) {
645 dprintf (("USER32: BeginPaint %x %x: invalid window handle!!", hWnd, lpps));
646 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); //(verified in NT4, SP6)
647 return (HDC)0;
648 }
649 bIcon = IsIconic(hwnd);
650
651 //check if the application previously didn't handle a WM_PAINT msg properly
652 wnd->checkForDirtyUpdateRegion();
653
654 HWND hwndClient = (bIcon) ? wnd->getOS2FrameWindowHandle() : wnd->getOS2WindowHandle();
655
656 if(hwnd != HWND_DESKTOP && !bIcon && wnd->isOwnDC())
657 {
658 hPS_ownDC = wnd->getOwnDC();
659 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
660 if(hPS_ownDC) {
661 pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
662 if (!pHps)
663 {
664 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
665 RELEASE_WNDOBJ(wnd);
666 SetLastError(ERROR_INVALID_PARAMETER_W);
667 return (HDC)NULLHANDLE;
668 }
669 hpsPaint = hPS_ownDC;
670 STATS_GetDCEx(hwnd, hpsPaint, 0, 0);
671 }
672 }
673 if(!hpsPaint) {
674 hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_USESTYLE_W | ((bIcon) ? DCX_WINDOW_W : 0)));
675 pHps = (pDCData)GpiQueryDCData(hpsPaint);
676 if (!pHps)
677 {
678 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
679 RELEASE_WNDOBJ(wnd);
680 SetLastError(ERROR_INVALID_PARAMETER_W);
681 return (HDC)NULLHANDLE;
682 }
683 }
684
685 if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE)
686 {
687 memset(&rectl, 0, sizeof(rectl));
688 dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
689
690 if(bIcon) {
691 //WinBeginPaint messes this up for icon windows; this isn't
692 //a good solution, but it does the job
693 //Use the entire frame window as clip region
694 rectl.xRight = wnd->getWindowWidth();
695 rectl.yTop = wnd->getWindowHeight();
696 }
697
698 //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
699 dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
700 wnd->SaveClipRegion(pHps->hrgnWin32Clip);
701 wnd->SaveVisRegion(pHps->hrgnWinVis);
702
703 //clear visible and clip regions
704 pHps->hrgnWin32Clip = NULLHANDLE;
705 pHps->hrgnWinVis = NULLHANDLE;
706
707 HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectl);
708 GdiSetVisRgn(pHps, hrgnVis);
709
710 selectClientArea(wnd, pHps);
711
712 if(bIcon) {
713 lComplexity = RGN_RECT;
714 }
715 else lComplexity = RGN_NULL;
716 }
717 else {
718 rectlClip.yBottom = rectlClip.xLeft = 0;
719 rectlClip.yTop = rectlClip.xRight = 1;
720
721 //Query update region
722 HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectlClip);
723 WinQueryUpdateRegion(hwndClient, hrgnVis);
724 WinValidateRegion(hwndClient, hrgnVis, FALSE);
725
726 dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnVis);
727
728#ifdef DEBUG
729 //Note: GpiQueryClipBox returns logical points
730 lComplexity = GpiQueryClipBox(pHps->hps, &rectlClip);
731 dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
732#endif
733
734 //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
735 dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
736 wnd->SaveClipRegion(pHps->hrgnWin32Clip);
737 wnd->SaveVisRegion(pHps->hrgnWinVis);
738
739 //clear visible and clip regions
740 pHps->hrgnWin32Clip = NULLHANDLE;
741 pHps->hrgnWinVis = NULLHANDLE;
742
743 //set clip region
744 lComplexity = GdiSetVisRgn(pHps, hrgnVis);
745
746 if(lComplexity == NULLREGION_W) {
747 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())));
748 }
749 else dprintf (("BeginPaint %x: (vis=%d/%d show=%d/%d)", hWnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()), WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
750
751 selectClientArea(wnd, pHps);
752
753#ifdef DEBUG
754 //Note: GpiQueryClipBox returns logical points
755 GpiQueryClipBox(pHps->hps, &rectlClip);
756 dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
757#endif
758 }
759
760 if(hPS_ownDC == 0)
761 setMapMode (wnd, pHps, MM_TEXT_W);
762 else
763 setPageXForm(wnd, pHps);
764
765 pHps->hdcType = TYPE_3;
766
767 HideCaret(hwnd);
768 WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
769
770 if((wnd->needsEraseBkgnd() || wnd->hasPMUpdateRegionChanged()) && lComplexity != RGN_NULL) {
771 wnd->setEraseBkgnd(FALSE);
772 wnd->SetPMUpdateRegionChanged(FALSE);
773 lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
774 }
775 else lpps->fErase = TRUE;
776
777 lpps->hdc = (HDC)pHps->hps;
778
779 if(lComplexity != RGN_NULL) {
780 long height = wnd->getClientHeight();
781 lpps->rcPaint.top = height - rectl.yTop;
782 lpps->rcPaint.left = rectl.xLeft;
783 lpps->rcPaint.bottom = height - rectl.yBottom;
784 lpps->rcPaint.right = rectl.xRight;
785 //BeginPaint must return logical points instead of device points.
786 //(not the same if e.g. app changes page viewport)
787 DPtoLP(lpps->hdc, (LPPOINT)&lpps->rcPaint, 2);
788 }
789 else {
790 lpps->rcPaint.bottom = lpps->rcPaint.top = 0;
791 lpps->rcPaint.right = lpps->rcPaint.left = 0;
792 }
793 RELEASE_WNDOBJ(wnd);
794
795 SetLastError(0);
796 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));
797 return (HDC)pHps->hps;
798}
799//******************************************************************************
800//******************************************************************************
801BOOL WIN32API EndPaint (HWND hWnd, const PAINTSTRUCT_W *pPaint)
802{
803 HWND hwnd = hWnd ? hWnd : HWND_DESKTOP;
804 pDCData pHps;
805
806 dprintf (("USER32: EndPaint(%x)", hwnd));
807
808 if (!pPaint || !pPaint->hdc )
809 return TRUE;
810
811 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
812
813 if (!wnd) goto exit;
814
815 pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
816 if (pHps && (pHps->hdcType == TYPE_3))
817 {
818 //restore previous visible and clip regions
819 if(pHps->hrgnWinVis) {
820 GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
821 pHps->hrgnWinVis = NULLHANDLE;
822 }
823 if(pHps->hrgnWin32Clip) {
824 GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
825 pHps->hrgnWin32Clip = NULLHANDLE;
826 }
827
828 GdiSetVisRgn(pHps, wnd->GetVisRegion());
829 GdiCombineVisRgnClipRgn(pHps, wnd->GetClipRegion(), RGN_AND_W);
830
831 wnd->SaveClipRegion(0);
832 wnd->SaveVisRegion(0);
833
834 pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
835 ReleaseDC(hwnd, pPaint->hdc);
836 }
837 else {
838 dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc));
839 }
840 wnd->setEraseBkgnd(TRUE);
841 ShowCaret(hwnd);
842 WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
843
844exit:
845 if(wnd) RELEASE_WNDOBJ(wnd);
846 SetLastError(0);
847 return TRUE;
848}
849//******************************************************************************
850//******************************************************************************
851int WIN32API ReleaseDC (HWND hwnd, HDC hdc)
852{
853 BOOL isOwnDC = FALSE;
854 int rc;
855
856 HWND hwndDC = WindowFromDC(hdc);
857
858 //hwndDC can be zero if the window has already been destroyed
859 if(hwndDC != hwnd) {
860 dprintf(("WARNING: ReleaseDC: wrong window handle specified %x -> %x", hwnd, hwndDC));
861 hwnd = hwndDC;
862 }
863
864 if (hwnd)
865 {
866 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
867 if(wnd == NULL) {
868 dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
869 return 0;
870 }
871 isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
872 if(!isOwnDC)
873 {
874 pDCData pHps = (pDCData)GpiQueryDCData((HPS)hdc);
875 if(pHps && pHps->psType == MICRO_CACHED) {
876 removeClientArea(wnd, pHps);
877 if(pHps->hrgnWinVis) {
878 GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
879 pHps->hrgnWinVis = 0;
880 }
881 if(pHps->hrgnWin32Clip) {
882 GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
883 pHps->hrgnWin32Clip = 0;
884 }
885 }
886 else {
887 dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
888 DebugInt3();
889 }
890 }
891 else {
892 dprintf2(("ReleaseDC: CS_OWNDC, not released"));
893 }
894 if(!isOwnDC && !wnd->isDesktopWindow()) {
895 //remove from list of open DCs for this window
896 wnd->removeOpenDC(hdc);
897 }
898 RELEASE_WNDOBJ(wnd);
899 }
900
901 STATS_ReleaseDC(hwnd, hdc);
902 if(isOwnDC) {
903 rc = TRUE;
904 }
905 else {
906 UnselectGDIObjects(hdc);
907 rc = O32_ReleaseDC (0, hdc);
908 }
909
910 dprintf(("ReleaseDC %x %x", hwnd, hdc));
911 return (rc);
912}
913//******************************************************************************
914// This implementation of GetDCEx supports:
915//
916// DCX_WINDOW
917// DCX_CACHE
918// DCX_EXCLUDERGN (complex regions allowed)
919// DCX_INTERSECTRGN (complex regions allowed)
920// DCX_USESTYLE
921// DCX_CLIPSIBLINGS
922// DCX_CLIPCHILDREN
923// DCX_PARENTCLIP
924//
925// Not supported:
926//
927// DCX_NORESETATTRS_W
928// DCX_INTERSECTUPDATE_W
929// DCX_LOCKWINDOWUPDATE_W
930// DCX_VALIDATE_W
931// DCX_EXCLUDEUPDATE_W
932//
933//TODO: WM_SETREDRAW affects drawingAllowed flag!!
934//******************************************************************************
935HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
936{
937 Win32BaseWindow *wnd = NULL;
938 HWND hWindow;
939 BOOL success;
940 pDCData pHps = NULL;
941 HPS hps = NULLHANDLE;
942 BOOL drawingAllowed = TRUE;
943 BOOL isWindowOwnDC;
944 BOOL creatingOwnDC = FALSE;
945 PS_Type psType;
946
947 if(flags & (DCX_NORESETATTRS_W | DCX_INTERSECTUPDATE_W | DCX_LOCKWINDOWUPDATE_W | DCX_VALIDATE_W | DCX_EXCLUDEUPDATE_W)) {
948 dprintf(("ERROR: GetDCEx: unsupported flags %x!!", flags));
949 DebugInt3();
950 }
951
952 if(hwnd == 0) {
953 dprintf(("error: GetDCEx window %x not found", hwnd));
954 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
955 return 0;
956 }
957
958 if(hwnd)
959 {
960 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
961 if(wnd == NULL) {
962 dprintf (("ERROR: User32: GetDCEx bad window handle %X!!!!!", hwnd));
963 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
964 return 0;
965 }
966 if(flags & DCX_WINDOW_W) {
967 hWindow = wnd->getOS2FrameWindowHandle();
968 }
969 else hWindow = wnd->getOS2WindowHandle();
970 }
971
972 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
973 && !(flags & (DCX_CACHE_W|DCX_WINDOW_W)));
974
975 if(isWindowOwnDC) //own dc always for client area
976 {
977 hps = wnd->getOwnDC();
978 if (hps)
979 {
980 pDCData pHps = (pDCData)GpiQueryDCData (hps);
981 if (!pHps)
982 goto error;
983
984 selectClientArea(wnd, pHps);
985
986 //TODO: Is this always necessary??
987 setPageXForm (wnd, pHps);
988 pHps->hdcType = TYPE_1;
989
990 //TODO: intersect/exclude clip region?
991 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
992
993 RELEASE_WNDOBJ(wnd);
994
995 STATS_GetDCEx(hwnd, hps, hrgn, flags);
996
997 return (HDC)hps;
998 }
999 else creatingOwnDC = TRUE;
1000 }
1001
1002 if(isWindowOwnDC)
1003 {
1004 SIZEL sizel = {0,0};
1005 hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
1006 WinOpenWindowDC (hWindow),
1007 &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
1008 psType = MICRO;
1009 // default cp is OS/2 one: set to windows default (ODIN.INI)
1010 GpiSetCp(hps, GetDisplayCodepage());
1011 }
1012 else
1013 {
1014 if (hWindow == HWND_DESKTOP) {
1015 hps = WinGetScreenPS (hWindow);
1016 }
1017 else {
1018 int clipstyle = 0;
1019 int clipwnd = HWND_TOP;
1020 if(flags & (DCX_USESTYLE_W))
1021 {
1022 int style = wnd->getStyle();
1023 if(style & WS_CLIPCHILDREN_W) {
1024 clipstyle |= PSF_CLIPCHILDREN;
1025 }
1026 if(style & WS_CLIPSIBLINGS_W) {
1027 clipstyle |= PSF_CLIPSIBLINGS;
1028 }
1029 if(wnd->fHasParentDC()) {
1030 clipstyle |= PSF_PARENTCLIP;
1031 }
1032 }
1033 if(flags & DCX_CLIPSIBLINGS_W) {
1034 clipstyle |= PSF_CLIPSIBLINGS;
1035 }
1036 if(flags & DCX_CLIPCHILDREN_W) {
1037 clipstyle |= PSF_CLIPCHILDREN;
1038 }
1039 if(flags & DCX_PARENTCLIP_W) {
1040 clipstyle |= PSF_PARENTCLIP;
1041 }
1042 //Always call WinGetClipPS; WinGetPS takes window & class style
1043 //into account
1044// if(clipstyle || !(flags & DCX_DEFAULTCLIP_W)) {
1045 dprintf2(("WinGetClipPS style %x", clipstyle));
1046 hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
1047// }
1048// else hps = WinGetPS (hWindow);
1049
1050 // default cp is OS/2 one: set to windows default (ODIN.INI)
1051 GpiSetCp(hps, GetDisplayCodepage());
1052 }
1053 psType = MICRO_CACHED;
1054 }
1055
1056 if (!hps)
1057 goto error;
1058
1059 HPSToHDC (hWindow, hps, NULL, NULL);
1060 pHps = (pDCData)GpiQueryDCData (hps);
1061
1062 if(flags & DCX_WINDOW_W) {
1063 removeClientArea(wnd, pHps);
1064 }
1065 else selectClientArea(wnd, pHps);
1066
1067 setMapMode(wnd, pHps, MM_TEXT_W);
1068
1069 if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
1070 {
1071 ULONG BytesNeeded;
1072 PRGNDATA RgnData;
1073 PRECT pr;
1074 int i;
1075 RECTL rectl;
1076
1077 if (!hrgn)
1078 goto error;
1079
1080 success = TRUE;
1081 if (flags & DCX_EXCLUDERGN_W)
1082 {//exclude specified region from visible region
1083 success = (GdiCombineVisRgn(pHps, hrgn, RGN_DIFF_W) != ERROR_W);
1084 }
1085 else //DCX_INTERSECTRGN_W
1086 {//intersect visible region with specified region
1087 success = (GdiCombineVisRgn(pHps, hrgn, RGN_AND_W) != ERROR_W);
1088 }
1089 if (!success)
1090 goto error;
1091 }
1092
1093 if (creatingOwnDC)
1094 wnd->setOwnDC ((HDC)hps);
1095
1096 pHps->psType = psType;
1097 pHps->hdcType = TYPE_1;
1098 //TODO: WM_SETREDRAW affects drawingAllowed flag!!
1099 GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
1100
1101 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
1102
1103 //add to list of open DCs for this window
1104 if(wnd->isDesktopWindow() == FALSE) {//not relevant for the desktop window
1105 wnd->addOpenDC((HDC)pHps->hps);
1106 }
1107
1108 RELEASE_WNDOBJ(wnd);
1109
1110 STATS_GetDCEx(hwnd, pHps->hps, hrgn, flags);
1111 return (HDC)pHps->hps;
1112
1113error:
1114 /* Something went wrong; clean up
1115 */
1116 dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));
1117 DebugInt3();
1118 if (pHps)
1119 {
1120 if (pHps->hps)
1121 {
1122 if(pHps->psType == MICRO_CACHED)
1123 WinReleasePS(pHps->hps);
1124 else
1125 GpiDestroyPS(pHps->hps);
1126 }
1127
1128 if (pHps->hdc) DevCloseDC(pHps->hdc);
1129 if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
1130
1131 O32_DeleteObject (pHps->nullBitmapHandle);
1132 }
1133 if(wnd) RELEASE_WNDOBJ(wnd);
1134 SetLastError(ERROR_INVALID_PARAMETER_W);
1135 return NULL;
1136}
1137//******************************************************************************
1138//******************************************************************************
1139HDC WIN32API GetDC (HWND hwnd)
1140{
1141 if(!hwnd)
1142 return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
1143
1144 return GetDCEx (hwnd, NULL, DCX_USESTYLE_W);
1145}
1146//******************************************************************************
1147//******************************************************************************
1148HDC WIN32API GetWindowDC (HWND hwnd)
1149{
1150 if (!hwnd) hwnd = GetDesktopWindow();
1151 return GetDCEx (hwnd, NULL, DCX_WINDOW_W | DCX_USESTYLE_W);
1152}
1153//******************************************************************************
1154//Helper for RedrawWindow (RDW_ALLCHILDREN_W)
1155//******************************************************************************
1156LRESULT WIN32API RedrawChildEnumProc(HWND hwnd, LPARAM lParam)
1157{
1158 RedrawWindow(hwnd, NULL, 0, lParam);
1159 return TRUE;
1160}
1161//******************************************************************************
1162// This implementation of RedrawWindow supports
1163// RDW_ERASE
1164// RDW_NOERASE
1165// RDW_INTERNALPAINT
1166// RDW_NOINTERNALPAINT
1167// RDW_INVALIDATE
1168// RDW_VALIDATE
1169// RDW_ERASENOW
1170// RDW_UPDATENOW
1171// RDW_FRAME
1172//
1173//TODO: Works ok for RDW_FRAME??
1174// SDK docs say RDW_FRAME is only valid for RDW_INVALIDATE...
1175//******************************************************************************
1176BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
1177{
1178 Win32BaseWindow *wnd;
1179
1180 if(pRect) {
1181 dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
1182 }
1183 else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
1184
1185 if(!IsWindowVisible(hwnd)) {
1186 dprintf(("WARNING: Invisible window -> ignoring RedrawWindow call"));
1187 return TRUE;
1188 }
1189
1190 if (hwnd == NULLHANDLE)
1191 {
1192 hwnd = HWND_DESKTOP;
1193 wnd = Win32BaseWindow::GetWindowFromOS2Handle(OSLIB_HWND_DESKTOP);
1194
1195 if (!wnd)
1196 {
1197 dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n",
1198 hwnd));
1199 SetLastError(ERROR_INVALID_PARAMETER_W);
1200 return FALSE;
1201 }
1202 }
1203 else
1204 {
1205 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1206
1207 if (!wnd)
1208 {
1209 dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n",
1210 hwnd));
1211 SetLastError(ERROR_INVALID_PARAMETER_W);
1212 return FALSE;
1213 }
1214 if(redraw & RDW_FRAME_W) {
1215 hwnd = wnd->getOS2FrameWindowHandle();
1216 }
1217 else hwnd = wnd->getOS2WindowHandle();
1218 }
1219
1220 //check if the application previously didn't handle a WM_PAINT msg properly
1221 wnd->checkForDirtyUpdateRegion();
1222
1223 BOOL IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE;
1224 BOOL success = TRUE;
1225 HPS hpsTemp = NULLHANDLE;
1226 HRGN hrgnTemp = NULLHANDLE;
1227 RECTL rectl;
1228
1229 if (hrgn)
1230 {
1231 ULONG BytesNeeded;
1232 PRGNDATA RgnData;
1233 PRECTL pr;
1234 int i;
1235 LONG height;
1236
1237 if(wnd) {
1238 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight();
1239 }
1240 else height = OSLibQueryScreenHeight();
1241
1242 if (!hrgn)
1243 goto error;
1244
1245 BytesNeeded = GetRegionData (hrgn, 0, NULL);
1246 RgnData = (PRGNDATA)_alloca (BytesNeeded);
1247 if (RgnData == NULL)
1248 goto error;
1249 GetRegionData (hrgn, BytesNeeded, RgnData);
1250
1251 pr = (PRECTL)(RgnData->Buffer);
1252 for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
1253 LONG temp = pr->yTop;
1254 pr->yTop = height - pr->yBottom;
1255 pr->yBottom = height - temp;
1256 dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));
1257 }
1258
1259 hpsTemp = WinGetScreenPS (HWND_DESKTOP);
1260 hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
1261 if (!hrgnTemp) goto error;
1262 }
1263 else if (pRect)
1264 {
1265 if(wnd) {
1266 if(redraw & RDW_FRAME_W) {
1267 mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
1268 }
1269 else mapWin32ToOS2Rect(wnd->getClientHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
1270 }
1271 else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
1272 }
1273
1274 if (redraw & RDW_INVALIDATE_W)
1275 {
1276 //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs
1277 if (redraw & RDW_ERASE_W) {
1278 wnd->setEraseBkgnd(TRUE);
1279 }
1280 else
1281 //Don't clear erase background flag if the window is
1282 //already (partly) invalidated
1283 if (!WinQueryUpdateRect (hwnd, NULL)) {
1284 dprintf(("RDW_INVALIDATE: no update rectangle, disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
1285 wnd->setEraseBkgnd(FALSE);
1286 }
1287
1288 if (!pRect && !hrgn)
1289 success = WinInvalidateRect (hwnd, NULL, IncludeChildren);
1290 else
1291 if (hrgn) {
1292 success = WinInvalidateRegion (hwnd, hrgnTemp, IncludeChildren);
1293 if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) {
1294 dprintf(("WARNING: WinQueryUpdateRect %x region %x returned false even though we just invalidated part of a window!!!", hwnd, hrgnTemp));
1295 success = success = WinInvalidateRegion (hwnd, hrgnTemp, FALSE);
1296 }
1297 }
1298 else {
1299 dprintf2(("WinInvalidateRect (%d,%d)(%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
1300 success = WinInvalidateRect (hwnd, &rectl, IncludeChildren);
1301//SvL: If all children are included, then WinInvalidateRect is called
1302// with fIncludeChildren=1 -> rect of hwnd isn't invalidated if child(ren)
1303// overlap(s) the specified rectangle completely (EVEN if window doesn't
1304// have WS_CLIPCHILREN!)
1305// -> example: XWing vs Tie Fighter install window
1306// WinInvalidateRect with fIncludeChildren=0 invalidates both the parent
1307// and child windows
1308//SvL: Can't always set fIncludeChildren to FALSE or else some controls in
1309// the RealPlayer setup application aren't redrawn when invalidating
1310// their parent
1311// SO: Check if IncludeChildren is set and part of the window is invalid
1312// If not -> call WinInvalidateRect with IncludeChildren=0 to force
1313// the window rectangle to be invalidated
1314//
1315 if(IncludeChildren && WinQueryUpdateRect(hwnd, NULL) == FALSE) {
1316 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));
1317 success = WinInvalidateRect (hwnd, &rectl, FALSE);
1318 }
1319 }
1320
1321 if (!success) goto error;
1322 }
1323 else if (redraw & RDW_VALIDATE_W)
1324 {
1325 if (redraw & RDW_NOERASE_W) {
1326 dprintf(("RDW_NOERASE: disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
1327 wnd->setEraseBkgnd(FALSE);
1328 }
1329 if (WinQueryUpdateRect (hwnd, NULL))
1330 {
1331 if(!pRect && !hrgn) {
1332 success = WinValidateRect (hwnd, NULL, IncludeChildren);
1333 }
1334 else
1335 if(hrgn) {
1336 success = WinValidateRegion (hwnd, hrgnTemp, IncludeChildren);
1337 }
1338 else {
1339 success = WinValidateRect (hwnd, &rectl, IncludeChildren);
1340 }
1341 if(!success) goto error;
1342 }
1343 }
1344
1345 if(WinQueryUpdateRect(hwnd, &rectl))
1346 {
1347 dprintf2(("Update region (%d,%d)(%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
1348 //TODO: Does this work if RDW_ALLCHILDREN is set??
1349 if(redraw & RDW_UPDATENOW_W)
1350 {
1351 dprintf(("RDW_UPDATENOW -> UpdateWindow"));
1352 UpdateWindow(wnd->getWindowHandle());
1353 }
1354 else
1355// if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))
1356 if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd())
1357 wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
1358// if(redraw & RDW_ALLCHILDREN_W) {
1359// EnumChildWindows(wnd->getWindowHandle(), RedrawChildEnumProc, redraw);
1360// }
1361 }
1362 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
1363 {
1364 dprintf(("Manual redraw"));
1365 if(redraw & RDW_UPDATENOW_W) {
1366 wnd->MsgPaint(0, FALSE);
1367 }
1368 else PostMessageA(hwnd, WINWM_PAINT, 0, 0);
1369 }
1370
1371error:
1372 /* clean up */
1373 if (hrgnTemp)
1374 GpiDestroyRegion (hpsTemp, hrgnTemp);
1375
1376 if (hpsTemp)
1377 WinReleasePS (hpsTemp);
1378
1379 if (!success) {
1380 dprintf(("RedrawWindow failure!"));
1381 SetLastError(ERROR_INVALID_PARAMETER_W);
1382 }
1383 if(wnd) RELEASE_WNDOBJ(wnd);
1384 return (success);
1385}
1386//******************************************************************************
1387//******************************************************************************
1388BOOL WIN32API UpdateWindow (HWND hwnd)
1389{
1390 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1391 RECTL rectl;
1392 BOOL rc;
1393
1394 if(!wnd) {
1395 dprintf (("ERROR: User32: UpdateWindow INVALID hwnd %x", hwnd));
1396 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
1397 return FALSE;
1398 }
1399
1400 //check if the application previously didn't handle a WM_PAINT msg properly
1401 wnd->checkForDirtyUpdateRegion();
1402
1403#ifdef DEBUG
1404 if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), &rectl))
1405 {
1406 RECT rectUpdate;
1407 mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, &rectUpdate);
1408
1409 dprintf (("User32: UpdateWindow hwnd %x: update rectangle (%d,%d)(%d,%d)", hwnd, rectUpdate.left, rectUpdate.top, rectUpdate.right, rectUpdate.bottom));
1410 }
1411 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))));
1412#endif
1413 //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
1414 // Breaks vpbuddy
1415 //rc = RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
1416 // -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window
1417 // handler; possibly bypassing queued WM_PAINT messages for parent window(s)
1418 // -> out of sync painting (i.e. parent paints over child)
1419
1420// if(!WinIsWindowShowing(wnd->getOS2FrameWindowHandle()) || !WinIsWindowShowing(wnd->getOS2WindowHandle())) {
1421// dprintf(("UpdateWindow: window not showing %d/%d", WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()) ));
1422// RELEASE_WNDOBJ(wnd);
1423// return FALSE;
1424// }
1425 //Must use frame window here. If the frame window has a valid update region and we call
1426 //WinUpdateWindow for the client window, then no WM_PAINT messages will be sent.
1427 rc = WinUpdateWindow(wnd->getOS2FrameWindowHandle());
1428#ifdef DEBUG
1429 if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), NULL))
1430 {
1431 //if parent has valid update region then WinUpdateWindow will still fail..
1432 //might be harmless and happen even in windows
1433 dprintf (("ERROR: User32: UpdateWindow didn't send WM_PAINT messages!!"));
1434 }
1435#endif
1436 RELEASE_WNDOBJ(wnd);
1437 return rc;
1438}
1439//******************************************************************************
1440//******************************************************************************
1441BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
1442{
1443 if(lprc) {
1444 dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
1445 }
1446 else dprintf(("USER32: ValidateRect %x", hwnd));
1447
1448 return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
1449}
1450//******************************************************************************
1451//******************************************************************************
1452BOOL WIN32API ValidateRgn( HWND hwnd, HRGN hrgn)
1453{
1454 dprintf(("USER32: ValidateRgn %x %x", hwnd, hrgn));
1455 return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
1456}
1457//******************************************************************************
1458//******************************************************************************
1459BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase)
1460{
1461 BOOL result;
1462
1463 if(pRect) {
1464 dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase));
1465 }
1466 else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
1467#if 1
1468 result = RedrawWindow (hwnd, pRect, NULLHANDLE,
1469 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
1470 (erase ? RDW_ERASE_W : 0) |
1471 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
1472#else
1473 result = RedrawWindow (hwnd, pRect, NULLHANDLE,
1474 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
1475 (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
1476 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
1477#endif
1478 return (result);
1479}
1480//******************************************************************************
1481//******************************************************************************
1482BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
1483{
1484 BOOL result;
1485
1486 dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
1487#if 1
1488 result = RedrawWindow (hwnd, NULL, hrgn,
1489 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
1490 (erase ? RDW_ERASE_W : 0) |
1491 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
1492#else
1493 result = RedrawWindow (hwnd, NULL, hrgn,
1494 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
1495 (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
1496 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
1497#endif
1498 return (result);
1499}
1500//******************************************************************************
1501//TODO: Change for client rectangle!!!!!
1502//******************************************************************************
1503BOOL setPMRgnIntoWinRgn (HPS hps, HRGN hrgnPM, HRGN hrgnWin, LONG height)
1504{
1505 BOOL rc;
1506 RGNRECT rgnRect;
1507 rgnRect.ircStart = 1;
1508 rgnRect.crc = 0;
1509 rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
1510
1511 rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, NULL);
1512
1513 if (rc && (rgnRect.crcReturned > 0))
1514 {
1515 PRECTL Rcls = new RECTL[rgnRect.crcReturned];
1516 PRECTL pRcl = Rcls;
1517
1518 if (Rcls != NULL)
1519 {
1520 rgnRect.crc = rgnRect.crcReturned;
1521 rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
1522
1523 rc = SetRectRgn(hrgnWin, pRcl->xLeft, height - pRcl->yTop,
1524 pRcl->xRight, height - pRcl->yBottom);
1525
1526 if (rgnRect.crcReturned > 1)
1527 {
1528 int i;
1529 HRGN temp;
1530 temp = CreateRectRgn (0, 0, 1, 1);
1531
1532 for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
1533 {
1534 rc = SetRectRgn (temp, pRcl->xLeft, height - pRcl->yTop,
1535 pRcl->xRight, height - pRcl->yBottom);
1536 rc &= CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
1537 }
1538 DeleteObject (temp);
1539 }
1540 delete[] Rcls;
1541 }
1542 else
1543 {
1544 rc = FALSE;
1545 }
1546 }
1547 else
1548 {
1549 rc = SetRectRgn (hrgnWin, 0, 0, 0, 0);
1550 }
1551
1552 return (rc);
1553}
1554//******************************************************************************
1555//Using WinScrollWindow to scroll child windows is better (smoother).
1556//******************************************************************************
1557INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
1558 HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
1559{
1560 Win32BaseWindow *window;
1561 APIRET rc;
1562 RECTL scrollRect;
1563 RECTL clipRect;
1564 PRECTL pScrollOS2 = NULL;
1565 PRECTL pClipOS2 = NULL;
1566 ULONG scrollFlagsOS2 = 0;
1567 int orgdy = dy;
1568 int regionType = ERROR_W;
1569
1570 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1571 if(!window) {
1572 dprintf(("ScrollWindowEx, window %x not found", hwnd));
1573 return 0;
1574 }
1575
1576 dprintf(("ScrollWindowEx %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
1577
1578 dy = revertDy (window, dy);
1579
1580 if (scrollFlag & SW_INVALIDATE_W) scrollFlagsOS2 |= SW_INVALIDATERGN;
1581 if (scrollFlag & SW_SCROLLCHILDREN_W) scrollFlagsOS2 |= SW_SCROLLCHILDREN;
1582
1583 if(pScroll) {
1584 mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pScroll, (PRECTLOS2)&scrollRect);
1585 pScrollOS2 = &scrollRect;
1586 }
1587
1588 if(pClip) {
1589 mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pClip, (PRECTLOS2)&clipRect);
1590 pClipOS2 = &clipRect;
1591 }
1592
1593 RECTL rectlUpdate;
1594 HRGN hrgn = NULLHANDLE;
1595 HPS hpsScreen = 0;
1596
1597 if(hrgnUpdate) {
1598 RECTL rectl = { 1, 1, 2, 2 };
1599
1600 hpsScreen = WinGetScreenPS (HWND_DESKTOP);
1601 hrgn = GpiCreateRegion(hpsScreen, 1, &rectl);
1602 }
1603
1604 if (scrollFlag & SW_SMOOTHSCROLL_W)
1605 {
1606 INT time = (scrollFlag >> 16) & 0xFFFF;
1607
1608 //CB: todo, scroll in several steps
1609 // is time in ms? time <-> iteration count?
1610 }
1611
1612 LONG lComplexity = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
1613 pScrollOS2, pClipOS2,
1614 hrgn, &rectlUpdate, scrollFlagsOS2);
1615 if (lComplexity == RGN_ERROR)
1616 {
1617 goto fail;
1618 }
1619
1620 //Notify children that they have moved (according to the SDK docs,
1621 //they only receive a WM_MOVE message)
1622 //(PM only does this for windows with CS_MOVENOTIFY class)
1623 //TODO: Verify this (no WM_WINDOWPOSCHANGING/ED?)
1624 if (scrollFlag & SW_SCROLLCHILDREN_W)
1625 {
1626 HWND hwndChild;
1627 RECT rectChild, rc;
1628
1629 dprintf(("ScrollWindowEx: Scroll child windows"));
1630 GetClientRect(hwnd, &rc);
1631 if (pScroll) IntersectRect(&rc, &rc, pScroll);
1632
1633 hwndChild = GetWindow(hwnd, GW_CHILD_W);
1634
1635 while(hwndChild)
1636 {
1637 Win32BaseWindow *child;
1638
1639 child = Win32BaseWindow::GetWindowFromHandle(hwndChild);
1640 if(!child) {
1641 dprintf(("ERROR: ScrollWindowEx, child %x not found", hwnd));
1642 goto fail;
1643 }
1644 rectChild = *child->getWindowRect();
1645 if(!pScroll || IntersectRect(&rectChild, &rectChild, &rc))
1646 {
1647 dprintf(("ScrollWindowEx: Scroll child window %x", hwndChild));
1648 child->ScrollWindow(dx, orgdy);
1649 }
1650 RELEASE_WNDOBJ(child);
1651 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT_W);
1652 }
1653 dprintf(("***ScrollWindowEx: Scroll child windows DONE"));
1654 }
1655
1656 RECT winRectUpdate;
1657
1658 mapOS2ToWin32Rect(window->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
1659
1660 if (pRectUpdate)
1661 *pRectUpdate = winRectUpdate;
1662
1663 if (hrgnUpdate) {
1664 rc = setPMRgnIntoWinRgn(hpsScreen, hrgn, hrgnUpdate, window->getClientHeight());
1665 GpiDestroyRegion(hpsScreen, hrgn);
1666 WinReleasePS(hpsScreen);
1667 }
1668
1669 // If the background is to be erased, then make it so
1670 if ((scrollFlag & SW_ERASE_W))
1671 {
1672 dprintf(("Set erase background flag to TRUE"));
1673 window->setEraseBkgnd(TRUE);
1674 }
1675
1676#if 0
1677 //SvL: WinScrollWindow already invalidates the area; no need to do it again
1678 //(call to invalidateRect was wrong; has to include erase flag)
1679 if ((scrollFlag & SW_INVALIDATE_W) &&
1680 ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
1681 {
1682 rc = RedrawWindow (hwnd, &winRectUpdate, NULLHANDLE,
1683 RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
1684 ((scrollFlag & SW_ERASE_W) ? RDW_ERASE_W : 0) |
1685 RDW_UPDATENOW_W);
1686
1687// rc = InvalidateRect (hwnd, &winRectUpdate, (scrollFlag & SW_ERASE_W) ? 1 : 0);
1688 if (rc == FALSE)
1689 {
1690 RELEASE_WNDOBJ(window);
1691 return (0);
1692 }
1693 }
1694#endif
1695
1696 switch (lComplexity)
1697 {
1698 case RGN_NULL:
1699 regionType = NULLREGION_W;
1700 break;
1701 case RGN_RECT:
1702 regionType = SIMPLEREGION_W;
1703 break;
1704 case RGN_COMPLEX:
1705 regionType = COMPLEXREGION_W;
1706 break;
1707 default:
1708 regionType = ERROR_W;
1709 break;
1710 }
1711
1712 RELEASE_WNDOBJ(window);
1713 return (regionType);
1714
1715fail:
1716 if(hrgn) GpiDestroyRegion(hpsScreen, hrgn);
1717 if(hpsScreen) WinReleasePS(hpsScreen);
1718 RELEASE_WNDOBJ(window);
1719 return ERROR_W;
1720}
1721//******************************************************************************
1722//******************************************************************************
1723BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
1724{
1725 dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
1726 return (ERROR_W != ScrollWindowEx(hwnd, dx, dy, pScroll, pClip, 0, NULL,
1727 (pScroll ? 0 : SW_SCROLLCHILDREN_W) |
1728 SW_INVALIDATE_W ));
1729}
1730//******************************************************************************
1731//******************************************************************************
1732HWND WIN32API WindowFromDC(HDC hdc)
1733{
1734 pDCData pHps = (pDCData)GpiQueryDCData( (HPS)hdc );
1735
1736 dprintf2(("USER32: WindowFromDC %x", hdc));
1737 if ( pHps )
1738 return OS2ToWin32Handle(pHps->hwnd);
1739 else
1740 return 0;
1741}
1742//******************************************************************************
1743//******************************************************************************
1744
Note: See TracBrowser for help on using the repository browser.