source: trunk/src/user32/dc.cpp

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

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