source: trunk/src/user32/pmwindow.cpp@ 9605

Last change on this file since 9605 was 9605, checked in by sandervl, 23 years ago

Always use windows system colors (even in OS/2 L&F mode)

File size: 77.4 KB
Line 
1/* $Id: pmwindow.cpp,v 1.192 2003-01-03 21:43:15 sandervl Exp $ */
2/*
3 * Win32 Window Managment Code for OS/2
4 *
5 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_WIN
13#define INCL_GPI
14#define INCL_DEV /* Device Function definitions */
15#define INCL_GPICONTROL /* GPI control Functions */
16#define INCL_DOSPROCESS
17#define INCL_DOSMODULEMGR
18#define INCL_DOSDEVICES
19#define INCL_DOSDEVIOCTL
20#define INCL_WINTRACKRECT
21
22#include <os2wrap.h>
23#include <odinwrap.h>
24#include <stdlib.h>
25#include <string.h>
26#include <win32type.h>
27#include <win32api.h>
28#include <winconst.h>
29#include <winuser32.h>
30#include <wprocess.h>
31#include <dbglog.h>
32#include <win32wbase.h>
33#include <win32dlg.h>
34#include "win32wdesktop.h"
35#include "pmwindow.h"
36#include "oslibwin.h"
37#include "oslibutil.h"
38#include "oslibgdi.h"
39#include "oslibmsg.h"
40#define INCLUDED_BY_DC
41#include "dc.h"
42#include <thread.h>
43#include <wprocess.h>
44#include "caret.h"
45#include "timer.h"
46#include <codepage.h>
47#include "syscolor.h"
48#include "options.h"
49#include "menu.h"
50#include <pmkbdhk.h>
51#include <pmscan.h>
52#include <winscan.h>
53#include <win\dbt.h>
54#include "dragdrop.h"
55#include "menu.h"
56
57#define DBG_LOCALLOG DBG_pmwindow
58#include "dbglocal.h"
59
60//define this to use the new code for WM_CALCVALIDRECT handling
61//#define USE_CALCVALIDRECT
62
63HMQ hmq = 0; /* Message queue handle */
64HAB hab = 0;
65RECTL desktopRectl = {0};
66ULONG ScreenWidth = 0;
67ULONG ScreenHeight = 0;
68ULONG ScreenBitsPerPel = 0;
69BOOL fOS2Look = FALSE;
70BOOL fForceMonoCursor = FALSE;
71BOOL fDragDropActive = FALSE;
72BOOL fDragDropDisabled = FALSE;
73
74
75#define PMMENU_MINBUTTON 0
76#define PMMENU_MAXBUTTON 1
77#define PMMENU_RESTOREBUTTON 2
78#define PMMENU_CLOSEBUTTON 3
79#define PMMENU_MINBUTTONDOWN 4
80#define PMMENU_MAXBUTTONDOWN 5
81#define PMMENU_RESTOREBUTTONDOWN 6
82#define PMMENU_CLOSEBUTTONDOWN 7
83
84HBITMAP hbmFrameMenu[8] = {0};
85
86//Win32 bitmap handles of the OS/2 min, max and restore buttons
87HBITMAP hBmpMinButton = 0;
88HBITMAP hBmpMaxButton = 0;
89HBITMAP hBmpRestoreButton = 0;
90HBITMAP hBmpCloseButton = 0;
91HBITMAP hBmpMinButtonDown = 0;
92HBITMAP hBmpMaxButtonDown = 0;
93HBITMAP hBmpRestoreButtonDown = 0;
94HBITMAP hBmpCloseButtonDown = 0;
95
96static PFNWP pfnFrameWndProc = NULL;
97static HWND hwndFocusChange = 0;
98 HWND hwndCD = 0;
99
100// this holds the font height that the display driver returns using DevQueryCaps
101// 13 would be small fonts, 16 medium fonts and 20 large fonts
102LONG CapsCharHeight = 0;
103
104// Note:
105// For a "lonekey"-press of AltGr, we only receive WM_KEYUP
106// messages. If the key is pressed longer and starts to repeat,
107// WM_KEYDOWN messages come in properly.
108static BOOL fKeyAltGrDown = FALSE;
109
110
111static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes);
112static BOOL PMDragValidate(PDRAGINFO pDragInfo);
113static void QueryPMMenuBitmaps();
114
115MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
116MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
117MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
118void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
119 HBITMAP hbmNew);
120void FrameSetFocus(HWND hwnd);
121
122VOID APIENTRY DspInitSystemDriverName(PSZ pszDriverName, ULONG lenDriverName);
123
124#ifdef DEBUG
125static char *DbgGetStringSWPFlags(ULONG flags);
126static char *DbgPrintQFCFlags(ULONG flags);
127#endif
128
129//******************************************************************************
130// Initialize PM; create hab, message queue and register special Win32 window classes
131//
132// This is called from the initterm, so we call it only once for each process.
133// We make sure PM is up and running for our purposes and init the existing
134// thread 0.
135//******************************************************************************
136BOOL InitPM()
137{
138 hab = WinInitialize(0);
139 dprintf(("Winitialize returned %x", hab));
140 hmq = WinCreateMsgQueue(hab, 0);
141
142 if(!hab || !hmq)
143 {
144 UINT error;
145 //CB: only fail on real error
146 error = WinGetLastError(hab) & 0xFFFF; //error code
147 if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
148 {
149 dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
150 dprintf((" Error = %x",error));
151 if(error == PMERR_NOT_IN_A_PM_SESSION) return TRUE;
152
153 return(FALSE);
154 }
155 else
156 {
157 if(!hab) {
158 hab = WinQueryAnchorBlock(HWND_DESKTOP);
159 dprintf(("WinQueryAnchorBlock returned %x", hab));
160 }
161 if(!hmq) {
162 PTIB ptib;
163 PPIB ppib;
164
165 DosGetInfoBlocks(&ptib, &ppib);
166
167 hmq = WinQueueFromID(hab, ppib->pib_ulpid, ptib->tib_ptib2->tib2_ultid);
168 }
169 }
170 }
171
172 // store our HAB and HMQ in the TEB - we need it quite often
173 // and they don't map 1:1 to Windows entities
174 SetThreadHAB(hab);
175 dprintf(("InitPM: hmq = %x", hmq));
176 SetThreadMessageQueue(hmq);
177
178 BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
179 dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
180
181 //CD polling window class
182 if(!WinRegisterClass( /* Register window class */
183 hab, /* Anchor block handle */
184 (PSZ)WIN32_CDCLASS, /* Window class name */
185 (PFNWP)Win32CDWindowProc, /* Address of window procedure */
186 0,
187 0))
188 {
189 dprintf(("WinRegisterClass Win32BaseWindow failed"));
190 return(FALSE);
191 }
192
193 //Standard Odin window class
194 if(!WinRegisterClass( /* Register window class */
195 hab, /* Anchor block handle */
196 (PSZ)WIN32_STDCLASS, /* Window class name */
197 (PFNWP)Win32WindowProc, /* Address of window procedure */
198 0,
199 NROF_WIN32WNDBYTES))
200 {
201 dprintf(("WinRegisterClass Win32BaseWindow failed"));
202 return(FALSE);
203 }
204
205 CLASSINFO FrameClassInfo;
206 if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
207 dprintf (("WinQueryClassInfo WC_FRAME failed"));
208 return (FALSE);
209 }
210 pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
211
212 dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
213
214 // this is our OS/2 window class for frame windows
215 if(!WinRegisterClass( /* Register window class */
216 hab, /* Anchor block handle */
217 (PSZ)WIN32_STDFRAMECLASS, /* Window class name */
218 (PFNWP)Win32FrameWindowProc, /* Address of window procedure */
219 CS_FRAME,
220 FrameClassInfo.cbWindowData))
221 {
222 dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
223 return(FALSE);
224 }
225
226 // get the screen dimensions and store them
227 WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
228 ScreenWidth = desktopRectl.xRight;
229 ScreenHeight = desktopRectl.yTop;
230
231 HDC hdc; /* Device-context handle */
232 /* context data structure */
233 DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
234 NULL, NULL, NULL};
235
236 /* create memory device context - it's temporary to query some information */
237 hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
238
239 // check if we have the OS/2 Look and Feel enabled
240 fOS2Look = PROFILE_GetOdinIniBool(ODINSYSTEM_SECTION, "OS2Look", FALSE);
241 if(fOS2Look)
242 {
243#if 0
244 SYSCOLOR_Init(FALSE); //use OS/2 colors
245#endif
246 QueryPMMenuBitmaps();
247 }
248
249 // find out which colordepth we're running
250 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
251
252 // query the font height to find out whether we have small or large fonts
253 DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_HEIGHT, 1, (PLONG)&CapsCharHeight);
254
255 DevCloseDC(hdc);
256
257 dprintf(("InitPM: Desktop (%d,%d) bpp %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel));
258 return TRUE;
259} /* End of main */
260//******************************************************************************
261HBITMAP OPEN32API _O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap);
262
263inline HBITMAP O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap)
264{
265 HBITMAP yyrc;
266 USHORT sel = RestoreOS2FS();
267
268 yyrc = _O32_CreateBitmapFromPMHandle(hPMBitmap);
269 SetFS(sel);
270
271 return yyrc;
272}
273//******************************************************************************
274static void QueryPMMenuBitmaps()
275{
276 CHAR szDisplay[30];
277 HMODULE hModDisplay;
278
279 if(hbmFrameMenu[0] == 0)
280 {
281 CHAR szDisplay[30];
282 HMODULE hModDisplay;
283 HDC hdc; /* Device-context handle */
284 DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
285 NULL, NULL, NULL};
286
287 /* create memory device context */
288 hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
289
290 DspInitSystemDriverName(szDisplay, sizeof(szDisplay));
291 DosQueryModuleHandle(szDisplay, &hModDisplay);
292
293 hbmFrameMenu[PMMENU_MINBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTON, 0, 0);
294 hbmFrameMenu[PMMENU_MINBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTONDEP, 0, 0);
295 hbmFrameMenu[PMMENU_MAXBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTON, 0, 0);
296 hbmFrameMenu[PMMENU_MAXBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTONDEP, 0, 0);
297 hbmFrameMenu[PMMENU_RESTOREBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTON, 0, 0);
298 hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTONDEP, 0, 0);
299 hbmFrameMenu[PMMENU_CLOSEBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSE, 0, 0);
300 hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSEDEP, 0, 0);
301
302 //Create win32 bitmap handles of the OS/2 min, max and restore buttons
303 hBmpMinButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTON]);
304 hBmpMinButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTONDOWN]);
305 hBmpMaxButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTON]);
306 hBmpMaxButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTONDOWN]);
307 hBmpRestoreButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTON]);
308 hBmpRestoreButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN]);
309 hBmpCloseButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTON]);
310 hBmpCloseButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN]);
311 DevCloseDC(hdc);
312 }
313}
314//******************************************************************************
315//******************************************************************************
316void WIN32API SetWindowAppearance(int fLooks)
317{
318 if(fLooks == OS2_APPEARANCE || fLooks == OS2_APPEARANCE_SYSMENU)
319 {
320#if 0
321 SYSCOLOR_Init(FALSE); //use OS/2 colors
322#endif
323 QueryPMMenuBitmaps();
324 }
325 fOS2Look = fLooks;
326 MENU_Init();
327}
328//******************************************************************************
329//******************************************************************************
330void WIN32API CustForceMonoCursor()
331{
332 fForceMonoCursor = TRUE;
333}
334//******************************************************************************
335//******************************************************************************
336void WIN32API DisableDragDrop(BOOL fDisabled)
337{
338 fDragDropDisabled = fDisabled;
339}
340//******************************************************************************
341//CD notification window class
342//******************************************************************************
343MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
344{
345#pragma pack(1)
346 typedef struct
347 {
348 BYTE ucCommandInfo;
349 WORD usDriveUnit;
350 } ParameterBlock;
351#pragma pack()
352
353 MRESULT rc = 0;
354 static ULONG drives[26] = {0};
355 static int drivestatus[26] = {0};
356
357 switch( msg )
358 {
359 //OS/2 msgs
360 case WM_CREATE:
361 {
362 char drive[4];
363
364 //skip floppy drives
365 drive[0] = 'C';
366 drive[1] = ':';
367 drive[2] = '\0';
368
369 for(int i=2;i<26;i++) {
370 drives[i] = GetDriveTypeA(drive);
371 if(drives[i] == DRIVE_CDROM_W)
372 {
373 DWORD parsize = sizeof(ParameterBlock);
374 DWORD datasize = 2;
375 WORD status = 0;
376 DWORD rc;
377 ParameterBlock parm;
378
379 parm.ucCommandInfo = 0;
380 parm.usDriveUnit = i;
381 rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
382 &status, sizeof(status), &datasize);
383 if(rc != NO_ERROR) {
384 dprintf(("DosDevIOCtl failed with rc %d", rc));
385 drives[i] = 0;
386 continue;
387 }
388 //if no disk present, return FALSE
389 if(status & 4) {
390 drivestatus[i] = status & 4;
391 }
392 }
393 drive[0]++;
394 }
395 WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*60);
396//// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*3);
397//// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 5000);
398 rc = (MRESULT)FALSE;
399 break;
400 }
401 case WM_TIMER:
402 {
403 for(int i=0;i<26;i++)
404 {
405 //for now only cdrom/dvd drives
406 if(drives[i] == DRIVE_CDROM_W)
407 {
408 DWORD parsize = sizeof(ParameterBlock);
409 DWORD datasize = 2;
410 WORD status = 0;
411 DWORD rc;
412 ParameterBlock parm;
413
414 parm.ucCommandInfo = 0;
415 parm.usDriveUnit = i;
416 rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
417 &status, sizeof(status), &datasize);
418 if(rc != NO_ERROR) {
419 dprintf(("DosDevIOCtl failed with rc %d", rc));
420 return FALSE;
421 }
422 //Send WM_DEVICECHANGE message when CD status changes
423 if((status & 4) != drivestatus[i])
424 {
425 PID pidThis, pidTemp;
426 HENUM henum;
427 HWND hwndEnum;
428 DEV_BROADCAST_VOLUME volchange;
429
430 dprintf(("Disk status 0x%x", status));
431
432 volchange.dbcv_size = sizeof(volchange);
433 volchange.dbcv_devicetype = DBT_DEVTYP_VOLUME;
434 volchange.dbcv_reserved = 0;
435 volchange.dbcv_unitmask = (1 << i);
436 volchange.dbcv_flags = DBTF_MEDIA;
437
438 WinQueryWindowProcess(hwnd, &pidThis, NULL);
439
440 //Iterate over all child windows of the desktop
441 henum = WinBeginEnumWindows(HWND_DESKTOP);
442
443 SetWin32TIB();
444 while(hwndEnum = WinGetNextWindow(henum))
445 {
446 WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
447 if(pidTemp == pidThis)
448 {
449 HWND hwndWin32 = OS2ToWin32Handle(hwndEnum);
450 if(hwndWin32) {
451 SendMessageA(hwndWin32,
452 WM_DEVICECHANGE_W,
453 (status & 4) ? DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE,
454 (LPARAM)&volchange);
455 }
456 }
457 }
458 RestoreOS2TIB();
459 WinEndEnumWindows(henum);
460
461 drivestatus[i] = (status & 4);
462 }
463 }
464 }
465 break;
466 }
467
468 case WM_DESTROY:
469 dprintf(("WM_DESTROY for CD notification window"));
470 WinStopTimer(hab, hwnd, TIMERID_DRIVEPOLL);
471 break;
472
473 default:
474 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
475 }
476 return (MRESULT)rc;
477}
478//******************************************************************************
479// Win32 window message handler
480// The PM window procedure for our client window class (non frame)
481//******************************************************************************
482MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
483{
484 Win32BaseWindow *win32wnd;
485 TEB *teb;
486 MSG winMsg, *pWinMsg;
487 MRESULT rc = 0;
488 POSTMSG_PACKET *postmsg;
489 OSLIBPOINT point, ClientPoint;
490
491 // restore our FS selector
492 SetWin32TIB();
493
494#ifdef DEBUG
495 dbg_ThreadPushCall("Win32WindowProc");
496#endif
497
498 // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- BEGIN
499 teb = GetThreadTEB();
500 win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
501
502//// dprintf(("window %x msg %x", (win32wnd) ? win32wnd->getWindowHandle() : 0, msg));
503
504 // do some sanity checking here:
505 // - we need to have a TEB handle
506 // - unless this is WM_CREATE (the very first message), there has to be
507 // a USER32 window object for this window handle
508 if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
509 dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
510 goto RunDefWndProc;
511 }
512//// if(teb->o.odin.fIgnoreMsgs) {
513//// goto RunDefWndProc;
514//// }
515
516 // check if the message state counter in the TEB is odd
517 // This means the message has been sent directly from PM to our message
518 // handler (so it is the first time we know about this PM message).
519 // If this is the case, we have to translate it here to a Win32
520 // message first. The other case is that the message is the result of a
521 // WinDispatchMsg call and therefore has already been translated.
522 if((teb->o.odin.msgstate & 1) == 0)
523 {
524 // message that was sent directly to our window proc handler; translate it here
525 QMSG qmsg;
526
527 qmsg.msg = msg;
528 qmsg.hwnd = hwnd;
529 qmsg.mp1 = mp1;
530 qmsg.mp2 = mp2;
531 qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
532 WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
533 qmsg.reserved = 0;
534
535 if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
536 {//message was not translated
537 memset(&winMsg, 0, sizeof(MSG));
538 }
539 pWinMsg = &winMsg;
540 }
541 else {
542 // message has already been translated before (GetMessage/PeekMessage).
543 // Use the translated information. Flip the translation flag.
544 pWinMsg = &teb->o.odin.msg;
545 teb->o.odin.msgstate++;
546 }
547 // END NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- END
548
549 if(msg >= WIN32APP_POSTMSG) {
550 //probably win32 app user message
551 dprintf2(("Posted message %x->%x", msg, msg-WIN32APP_POSTMSG));
552 if((ULONG)mp1 == WIN32MSG_MAGICA) {
553 rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
554 }
555 else
556 if((ULONG)mp1 == WIN32MSG_MAGICW) {
557 rc = (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
558 }
559 else {//broadcasted message
560 rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
561 }
562 RELEASE_WNDOBJ(win32wnd);
563 RestoreOS2TIB();
564
565#ifdef DEBUG
566 dbg_ThreadPopCall();
567#endif
568 return rc;
569 }
570
571 switch( msg )
572 {
573 //OS/2 msgs
574 case WM_CREATE:
575 {
576 if(teb->o.odin.newWindow == 0)
577 goto createfail;
578
579 //Processing is done in after WinCreateWindow returns
580 dprintf(("OS2: WM_CREATE %x", hwnd));
581 win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
582 win32wnd->addRef();
583 teb->o.odin.newWindow = 0;
584 if(win32wnd->MsgCreate(hwnd) == FALSE)
585 {
586 rc = (MRESULT)TRUE; //discontinue window creation
587 break;
588 }
589
590 //Create CD notification window
591 if(hwndCD == 0) {
592 hwndCD = WinCreateWindow(HWND_DESKTOP, WIN32_CDCLASS,
593 NULL, 0, 0, 0, 0, 0,
594 HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
595 }
596
597 createfail:
598 rc = (MRESULT)FALSE;
599 break;
600 }
601
602 case WM_QUIT:
603 dprintf(("OS2: WM_QUIT %x", hwnd));
604 win32wnd->MsgQuit();
605 break;
606
607 case WM_CLOSE:
608 dprintf(("OS2: WM_CLOSE %x", hwnd));
609 win32wnd->MsgClose();
610 break;
611
612 case WM_DESTROY:
613 dprintf(("OS2: WM_DESTROY %x", hwnd));
614 win32wnd->MsgDestroy();
615 WinSetVisibleRegionNotify(hwnd, FALSE);
616 goto RunDefWndProc;
617
618 case WM_ENABLE:
619 dprintf(("OS2: WM_ENABLE %x", hwnd));
620 break;
621
622 case WM_SHOW:
623 dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
624 win32wnd->MsgShow((ULONG)mp1);
625 break;
626
627 case WM_ACTIVATE:
628 {
629 ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
630
631 dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
632 WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
633 if(win32wnd->IsWindowCreated())
634 {
635 win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
636 }
637 break;
638 }
639
640 case WM_SIZE:
641 {
642 dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
643 win32wnd->SetVisibleRegionChanged(TRUE);
644 goto RunDefWndProc;
645 }
646
647
648 case WM_VRNENABLED:
649 dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
650 //Always call handler; even if mp1 is 0. If we don't do this, the
651 //DivX 4 player will never be allowed to draw after putting another window
652 //on top of it.
653 win32wnd->callVisibleRgnNotifyProc(TRUE);
654 if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
655 {
656 HWND hwndrelated;
657 Win32BaseWindow *topwindow;
658
659 win32wnd->setComingToTop(TRUE);
660
661 hwndrelated = WinQueryWindow(hwnd, QW_PREV);
662 dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
663 topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
664 if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
665 //put window at the top of z order
666 WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
667 }
668 if(topwindow) RELEASE_WNDOBJ(topwindow);
669
670 win32wnd->setComingToTop(FALSE);
671 break;
672 }
673 goto RunDefWndProc;
674
675 case WM_VRNDISABLED:
676 dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
677 //visible region is about to change or WinLockWindowUpdate called
678 //suspend window drawing
679 win32wnd->callVisibleRgnNotifyProc(FALSE);
680 goto RunDefWndProc;
681
682 case WIN32APP_DDRAWFULLSCREEN:
683 //Changing the size of the win32 window in SetCooperativeLevel can
684 //fail if this happens during WM_ADJUSTWINDOWPOS
685 //NOTE: This is not a good solution, but a proper fix is more difficult
686 // with the current window mess
687 dprintf(("WIN32APP_DDRAWFULLSCREEN %x (%d,%d)", win32wnd->getWindowHandle(), mp1, mp2));
688 SetWindowPos(win32wnd->getWindowHandle(), HWND_TOP_W, 0, 0, (DWORD)mp1, (DWORD)mp2, 0);
689 ShowWindow(win32wnd->getWindowHandle(), SW_SHOW_W);
690 break;
691
692 case WIN32APP_SETFOCUSMSG:
693 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
694 //must delay this function call
695 //mp1 = win32 window handle
696 //mp2 = top parent if activation required
697 dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
698 if(teb->o.odin.hwndFocus) {
699 RELEASE_WNDOBJ(win32wnd);
700 win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
701 if(win32wnd) {
702 if(mp2) {
703 SetActiveWindow((HWND)mp2);
704 }
705 if(!IsWindow(win32wnd->getWindowHandle())) break; //abort if window destroyed
706 WinFocusChange(HWND_DESKTOP, win32wnd->getOS2WindowHandle(), FC_NOSETACTIVE);
707 }
708 else DebugInt3();
709 }
710 break;
711
712 case WM_SETFOCUS:
713 {
714 HWND hwndFocus = (HWND)mp1;
715
716 dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2));
717
718 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
719 //must delay this function call
720
721 teb->o.odin.fWM_SETFOCUS = TRUE;
722 teb->o.odin.hwndFocus = 0;
723 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
724 {
725 //another (non-win32) application's window
726 //set to NULL (allowed according to win32 SDK) to avoid problems
727 hwndFocus = NULL;
728 }
729 if((ULONG)mp2 == TRUE) {
730 HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
731 recreateCaret (hwndFocusWin32);
732 win32wnd->MsgSetFocus(hwndFocusWin32);
733 }
734 else win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
735 teb->o.odin.fWM_SETFOCUS = FALSE;
736
737 break;
738 }
739
740 //**************************************************************************
741 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
742 //**************************************************************************
743
744 case WM_BUTTON1DOWN:
745 case WM_BUTTON1UP:
746 case WM_BUTTON1DBLCLK:
747 case WM_BUTTON2DOWN:
748 case WM_BUTTON2UP:
749 case WM_BUTTON2DBLCLK:
750 case WM_BUTTON3DOWN:
751 case WM_BUTTON3UP:
752 case WM_BUTTON3DBLCLK:
753 if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
754 RELEASE_WNDOBJ(win32wnd);
755 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
756 }
757 if(win32wnd)
758 win32wnd->MsgButton(pWinMsg);
759
760 rc = (MRESULT)TRUE;
761 break;
762
763 case WM_BUTTON2MOTIONSTART:
764 case WM_BUTTON2MOTIONEND:
765 case WM_BUTTON2CLICK:
766 case WM_BUTTON1MOTIONSTART:
767 case WM_BUTTON1MOTIONEND:
768 case WM_BUTTON1CLICK:
769 case WM_BUTTON3MOTIONSTART:
770 case WM_BUTTON3MOTIONEND:
771 case WM_BUTTON3CLICK:
772 rc = (MRESULT)TRUE;
773 break;
774
775 case WM_MOUSEMOVE:
776 {
777 if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
778 RELEASE_WNDOBJ(win32wnd);
779 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
780 }
781 if(win32wnd)
782 win32wnd->MsgMouseMove(pWinMsg);
783 break;
784 }
785
786 case WM_CONTROL:
787 goto RunDefWndProc;
788
789 case WM_COMMAND:
790 dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
791 win32wnd->DispatchMsgA(pWinMsg);
792 break;
793
794 case WM_SYSCOMMAND:
795 dprintf(("OS2: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
796 win32wnd->DispatchMsgA(pWinMsg);
797 break;
798
799 case WM_RENDERFMT:
800 case WM_RENDERALLFMTS:
801 case WM_DESTROYCLIPBOARD:
802 case WM_DRAWCLIPBOARD:
803 win32wnd->DispatchMsgA(pWinMsg);
804 break;
805
806 case WM_CHAR_SPECIAL:
807 /* NO BREAK! FALLTHRU CASE! */
808
809 case WM_CHAR:
810 dprintf(("OS2: WM_CHAR %x %x %x, %x %x", win32wnd->getWindowHandle(), mp1, mp2, pWinMsg->wParam, pWinMsg->lParam));
811 win32wnd->MsgChar(pWinMsg);
812 break;
813
814 case WM_TIMER:
815 dprintf(("OS2: WM_TIMER %x %x time %x", win32wnd->getWindowHandle(), pWinMsg->wParam, GetTickCount()));
816 win32wnd->DispatchMsgA(pWinMsg);
817 goto RunDefWndProc;
818
819 case WM_SETWINDOWPARAMS:
820 {
821 WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
822
823 dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
824 if(wndParams->fsStatus & WPM_TEXT) {
825 win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
826 }
827 goto RunDefWndProc;
828 }
829
830 case WM_QUERYWINDOWPARAMS:
831 {
832 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
833 ULONG textlen;
834 PSZ wintext;
835
836 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
837 {
838 if(wndpars->fsStatus & WPM_TEXT)
839 win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
840 if(wndpars->fsStatus & WPM_CCHTEXT)
841 wndpars->cchText = win32wnd->MsgGetTextLength();
842
843 wndpars->fsStatus = 0;
844 wndpars->cbCtlData = 0;
845 wndpars->cbPresParams = 0;
846 rc = (MRESULT)TRUE;
847 break;
848 }
849 goto RunDefWndProc;
850 }
851
852 case WM_PAINT:
853 {
854 RECTL rectl;
855 BOOL rc;
856
857 rc = WinQueryUpdateRect(hwnd, &rectl);
858 dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
859
860 if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
861 rectl.yBottom != rectl.yTop) && !IsIconic(win32wnd->GetTopParent()))
862 {
863 win32wnd->DispatchMsgA(pWinMsg);
864 }
865 else goto RunDefWndProc;
866 break;
867 }
868
869 case WM_ERASEBACKGROUND:
870 {
871 dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
872 rc = (MRESULT)FALSE;
873 break;
874 }
875
876 case WM_CALCVALIDRECTS:
877 dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
878 rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
879 break;
880
881 case WM_REALIZEPALETTE:
882 {
883 dprintf(("OS2: WM_REALIZEPALETTE"));
884 goto RunDefWndProc;
885 }
886
887 case WM_HSCROLL:
888 case WM_VSCROLL:
889 dprintf(("OS2: %s %x %x %x", (msg == WM_HSCROLL) ? "WM_HSCROLL" : "WM_VSCROLL", win32wnd->getWindowHandle(), mp1, mp2));
890 win32wnd->DispatchMsgA(pWinMsg);
891 break;
892
893 case DM_DRAGOVER:
894 {
895 PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
896 PDRAGITEM pDragItem;
897 USHORT sxDrop = SHORT1FROMMP(mp2);
898 USHORT syDrop = SHORT2FROMMP(mp2);
899
900 dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
901
902 if(fDragDropDisabled) {
903 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
904 break;
905 }
906
907 //does this window accept dropped files?
908 if(!DragDropAccept(win32wnd->getWindowHandle())) {
909 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
910 break;
911 }
912
913 if(PMDragValidate(pDragInfo) == FALSE) {
914 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
915 break;
916 }
917 if(win32wnd->isDragDropActive() == FALSE) {
918 ULONG ulBytes, cItems;
919 char *pszFiles;
920
921 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
922 if(pszFiles) {
923 POINT point = {sxDrop, syDrop};
924 if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) {
925 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
926 }
927 else {
928 fDragDropActive = TRUE;
929 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
930 win32wnd->setDragDropActive(TRUE);
931 }
932 free(pszFiles);
933 }
934 else {
935 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
936 }
937 }
938 else {
939 if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) {
940 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
941 }
942 else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
943 }
944 break;
945 }
946
947 case DM_DRAGLEAVE:
948 {
949 dprintf(("OS2: DM_DRAGLEAVE %x", win32wnd->getWindowHandle()));
950
951 if(fDragDropDisabled) {
952 break;
953 }
954
955 fDragDropActive = FALSE;
956
957 //does this window accept dropped files?
958 if(!DragDropAccept(win32wnd->getWindowHandle())) {
959 break;
960 }
961
962 DragDropDragLeave(win32wnd->getWindowHandle());
963 win32wnd->setDragDropActive(FALSE);
964 break;
965 }
966
967 case DM_DROP:
968 {
969 PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
970 PDRAGITEM pDragItem;
971 USHORT sxDrop = SHORT1FROMMP(mp2);
972 USHORT syDrop = SHORT2FROMMP(mp2);
973 USHORT usIndicator, usOp;
974
975 dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
976
977 fDragDropActive = FALSE;
978 rc = (MRFROM2SHORT (DOR_NODROP, 0));
979
980 if(fDragDropDisabled) {
981 rc = (MRFROM2SHORT (DOR_NODROP, 0));
982 break;
983 }
984
985 //does this window accept dropped files?
986 if(!DragDropAccept(win32wnd->getWindowHandle())) {
987 break;
988 }
989
990 ULONG ulBytes, cItems;
991 char *pszFiles;
992
993 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
994 if(pszFiles) {
995 POINT point = {sxDrop, syDrop};
996 if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) {
997 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
998 }
999 else {
1000 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
1001 win32wnd->setDragDropActive(FALSE);
1002 }
1003 free(pszFiles);
1004 }
1005 else {
1006 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
1007 }
1008 break;
1009 }
1010
1011 case WM_DDE_INITIATE:
1012 case WM_DDE_INITIATEACK:
1013 case WM_DDE_REQUEST:
1014 case WM_DDE_ACK:
1015 case WM_DDE_DATA:
1016 case WM_DDE_ADVISE:
1017 case WM_DDE_UNADVISE:
1018 case WM_DDE_POKE:
1019 case WM_DDE_EXECUTE:
1020 case WM_DDE_TERMINATE:
1021 dprintf(("OS2: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
1022 goto RunDefWndProc;
1023
1024 case WM_INITMENU:
1025 case WM_MENUSELECT:
1026 case WM_MENUEND:
1027 case WM_NEXTMENU:
1028 case WM_SYSCOLORCHANGE:
1029 case WM_SYSVALUECHANGED:
1030 case WM_SETSELECTION:
1031 case WM_PPAINT:
1032 case WM_PSETFOCUS:
1033 case WM_PSYSCOLORCHANGE:
1034 case WM_PSIZE:
1035 case WM_PACTIVATE:
1036 case WM_PCONTROL:
1037 case WM_HELP:
1038 case WM_APPTERMINATENOTIFY:
1039 case WM_PRESPARAMCHANGED:
1040 case WM_DRAWITEM:
1041 case WM_MEASUREITEM:
1042 case WM_CONTROLPOINTER:
1043 case WM_QUERYDLGCODE:
1044 case WM_SUBSTITUTESTRING:
1045 case WM_MATCHMNEMONIC:
1046 case WM_SAVEAPPLICATION:
1047 case WM_SEMANTICEVENT:
1048 default:
1049 dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
1050 goto RunDefWndProc;
1051 }
1052 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
1053 RestoreOS2TIB();
1054
1055#ifdef DEBUG
1056 dbg_ThreadPopCall();
1057#endif
1058 return (MRESULT)rc;
1059
1060RunDefWndProc:
1061// dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
1062 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
1063 RestoreOS2TIB();
1064
1065#ifdef DEBUG
1066 dbg_ThreadPopCall();
1067#endif
1068 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
1069} /* End of Win32WindowProc */
1070//******************************************************************************
1071//******************************************************************************
1072MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1073{
1074 POSTMSG_PACKET *postmsg;
1075 OSLIBPOINT point, ClientPoint;
1076 Win32BaseWindow *win32wnd;
1077 TEB *teb;
1078 MRESULT rc = 0;
1079 MSG winMsg, *pWinMsg;
1080
1081#ifdef DEBUG
1082 dbg_ThreadPushCall("Win32FrameWindowProc");
1083#endif
1084
1085 //Restore our FS selector
1086 SetWin32TIB();
1087
1088 // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
1089 teb = GetThreadTEB();
1090 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
1091
1092 // do some sanity checking here:
1093 // - we need to have a TEB handle
1094 // - unless this is WM_CREATE (the very first message), there has to be
1095 // a USER32 window object for this window handle
1096 if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
1097 dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
1098 goto RunDefFrameWndProc;
1099 }
1100//// if(teb->o.odin.fIgnoreMsgs) {
1101//// goto RunDefWndProc;
1102//// }
1103
1104 // check if the message state counter in the TEB is odd
1105 // This means the message has been sent directly from PM to our message
1106 // handler (so it is the first time we know about this PM message).
1107 // If this is the case, we have to translate it here to a Win32
1108 // message first. The other case is that the message is the result of a
1109 // WinDispatchMsg call and therefore has already been translated.
1110 if((teb->o.odin.msgstate & 1) == 0)
1111 {//message that was sent directly to our window proc handler; translate it here
1112 QMSG qmsg;
1113
1114 qmsg.msg = msg;
1115 qmsg.hwnd = hwnd;
1116 qmsg.mp1 = mp1;
1117 qmsg.mp2 = mp2;
1118 qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
1119 WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
1120 qmsg.reserved = 0;
1121
1122 if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
1123 {//message was not translated
1124 memset(&winMsg, 0, sizeof(MSG));
1125 }
1126 pWinMsg = &winMsg;
1127 }
1128 else {
1129 // message has already been translated before (GetMessage/PeekMessage).
1130 // Use the translated information. Flip the translation flag.
1131 pWinMsg = &teb->o.odin.msg;
1132 teb->o.odin.msgstate++;
1133 }
1134 // END NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
1135
1136 switch( msg )
1137 {
1138 case WM_CREATE:
1139 {
1140 //WM_CREATE handled during client window creation
1141 dprintf(("PMFRAME: WM_CREATE %x", hwnd));
1142 goto RunDefFrameWndProc;
1143 }
1144
1145//hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
1146// handler; must postpone it, so do it here
1147 case WIN32APP_POSTPONEDESTROY:
1148 OSLibWinDestroyWindow(hwnd);
1149 break;
1150//hack end
1151
1152#ifdef DEBUG
1153 case WM_CLOSE:
1154 {
1155 dprintf(("PMFRAME: WM_CLOSE %x", hwnd));
1156 goto RunDefFrameWndProc;
1157 }
1158#endif
1159
1160 case WM_PAINT:
1161 {
1162 RECTL rectl;
1163
1164 HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
1165 dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
1166
1167 if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
1168 rectl.yBottom != rectl.yTop))
1169 {
1170 PRECT pClient = win32wnd->getClientRectPtr();
1171 PRECT pWindow = win32wnd->getWindowRect();
1172
1173 if(!(pClient->left == 0 && pClient->top == 0 &&
1174 win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
1175 win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
1176 {
1177 RECT rectUpdate;
1178
1179 mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
1180 win32wnd->MsgNCPaint(&rectUpdate);
1181 }
1182 }
1183 WinEndPaint(hps);
1184 break;
1185 }
1186
1187 case WM_ERASEBACKGROUND:
1188 {
1189 dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
1190 rc = (MRESULT)FALSE;
1191 break;
1192 }
1193
1194 //**************************************************************************
1195 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
1196 //**************************************************************************
1197
1198 case WM_BUTTON1DOWN:
1199 case WM_BUTTON1UP:
1200 case WM_BUTTON1DBLCLK:
1201 case WM_BUTTON2DOWN:
1202 case WM_BUTTON2UP:
1203 case WM_BUTTON2DBLCLK:
1204 case WM_BUTTON3DOWN:
1205 case WM_BUTTON3UP:
1206 case WM_BUTTON3DBLCLK:
1207 if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
1208 RELEASE_WNDOBJ(win32wnd);
1209 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
1210 }
1211 if(win32wnd)
1212 win32wnd->MsgButton(pWinMsg);
1213
1214 rc = (MRESULT)TRUE;
1215 break;
1216
1217 case WM_BUTTON2MOTIONSTART:
1218 case WM_BUTTON2MOTIONEND:
1219 case WM_BUTTON2CLICK:
1220 case WM_BUTTON1MOTIONSTART:
1221 case WM_BUTTON1MOTIONEND:
1222 case WM_BUTTON1CLICK:
1223 case WM_BUTTON3MOTIONSTART:
1224 case WM_BUTTON3MOTIONEND:
1225 case WM_BUTTON3CLICK:
1226 rc = (MRESULT)TRUE;
1227 break;
1228
1229 case WM_MOUSEMOVE:
1230 {
1231 if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
1232 RELEASE_WNDOBJ(win32wnd);
1233 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
1234 }
1235 if(win32wnd)
1236 win32wnd->MsgMouseMove(pWinMsg);
1237 break;
1238 }
1239
1240 case WM_ADJUSTWINDOWPOS:
1241 {
1242 PSWP pswp = (PSWP)mp1;
1243 SWP swpOld;
1244 WINDOWPOS wp,wpOld;
1245 ULONG ulFlags;
1246 ULONG ret = 0;
1247 HWND hParent = NULLHANDLE, hwndAfter;
1248
1249 dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
1250
1251 ulFlags = pswp->fl;
1252
1253 if(win32wnd->IsParentChanging()) {
1254 rc = 0;
1255 break;
1256 }
1257
1258 //@@PF all commands from minimized window viewer or from Ctrl-Esc
1259 //are 'pure' and should be handled only by DeFrameProc - this is weird
1260 //but without them we will not have results. Pure = plain flag of restore/minimize/maximize
1261 if((pswp->fl == SWP_MINIMIZE) || (pswp->fl & SWP_RESTORE)) {
1262 // note the purity of SWP no other SWP_FLAGS allowed
1263 goto RunDefFrameWndProc;
1264 }
1265
1266 if(pswp->fl & SWP_NOADJUST) {
1267 //ignore weird messages (TODO: why are they sent?)
1268 dprintf(("WARNING: WM_ADJUSTWINDOWPOS with SWP_NOADJUST flag!!"));
1269 break;
1270 }
1271 if ((pswp->fl == SWP_FOCUSACTIVATE) || (pswp->fl == SWP_FOCUSDEACTIVATE))
1272 {
1273 dprintf(("Pure focus flags are not sent to win32 windows"));
1274 goto RunDefFrameWndProc;
1275 }
1276
1277 //CB: show dialog in front of owner
1278 if (win32wnd->IsModalDialogOwner())
1279 {
1280 dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
1281 pswp->fl |= SWP_ZORDER;
1282 pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
1283 if (pswp->fl & SWP_ACTIVATE)
1284 {
1285 pswp->fl &= ~SWP_ACTIVATE;
1286 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
1287 }
1288 }
1289
1290 if(!win32wnd->CanReceiveSizeMsgs())
1291 break;
1292
1293 WinQueryWindowPos(hwnd, &swpOld);
1294 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
1295 if (win32wnd->isChild()) {
1296 if(win32wnd->getParent()) {
1297 hParent = win32wnd->getParent()->getOS2WindowHandle();
1298 }
1299 else goto RunDefFrameWndProc;
1300 }
1301 }
1302 hwndAfter = pswp->hwndInsertBehind;
1303 if(win32wnd->getParent()) {
1304 OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
1305 }
1306 else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
1307
1308 wp.hwnd = win32wnd->getWindowHandle();
1309 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
1310 {
1311 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
1312 dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
1313 if(wndAfter) {
1314 wp.hwndInsertAfter = wndAfter->getWindowHandle();
1315 RELEASE_WNDOBJ(wndAfter);
1316 }
1317 else wp.hwndInsertAfter = HWND_TOP_W;
1318 }
1319
1320 wpOld = wp;
1321 win32wnd->MsgPosChanging((LPARAM)&wp);
1322
1323 if(win32wnd->getOldStyle() != win32wnd->getStyle())
1324 {
1325 OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), win32wnd->getStyle(), win32wnd->getExStyle());
1326 if(fOS2Look) {
1327 DWORD dwOldStyle = win32wnd->getOldStyle();
1328 DWORD dwStyle = win32wnd->getStyle();
1329
1330 win32wnd->setOldStyle(dwStyle);
1331 if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
1332 //SC_RESTORE -> SC_MINIMIZE
1333 dprintf(("%x -> SC_RESTORE -> SC_MINIMIZE", win32wnd->getWindowHandle()));
1334 FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_RESTORE, SC_MINIMIZE, hbmFrameMenu[PMMENU_MINBUTTON]);
1335 if(dwStyle & WS_MAXIMIZE_W) {
1336 //SC_MAXIMIZE -> SC_RESTORE
1337 dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
1338 FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
1339 }
1340 }
1341 else
1342 if((dwOldStyle & WS_MAXIMIZE_W) && !(dwStyle & WS_MAXIMIZE_W)) {
1343 //SC_RESTORE -> SC_MAXIMIZE
1344 dprintf(("%x -> SC_RESTORE -> SC_MAXIMIZE", win32wnd->getWindowHandle()));
1345 FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_RESTORE, SC_MAXIMIZE, hbmFrameMenu[PMMENU_MAXBUTTON]);
1346 }
1347 else
1348 if(!(dwOldStyle & WS_MINIMIZE_W) && (dwStyle & WS_MINIMIZE_W)) {
1349 //SC_MINIMIZE -> SC_RESTORE
1350 dprintf(("%x -> SC_MINIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
1351 FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_MINIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
1352 }
1353 else
1354 if(!(dwOldStyle & WS_MAXIMIZE_W) && (dwStyle & WS_MAXIMIZE_W)) {
1355 //SC_MAXIMIZE -> SC_RESTORE
1356 dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
1357 FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
1358 }
1359 }
1360 }
1361
1362 if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
1363 (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
1364 {
1365 ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
1366
1367 dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
1368 dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
1369
1370 if(win32wnd->getParent()) {
1371 OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
1372 hwnd);
1373 }
1374 else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
1375
1376 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
1377
1378 //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
1379 if(pswp->fl & SWP_SIZE)
1380 flags |= SWP_SIZE;
1381
1382 if(pswp->fl & SWP_MOVE)
1383 flags |= SWP_MOVE;
1384
1385 pswp->fl = flags; //restore flags
1386
1387 pswp->fl |= SWP_NOADJUST;
1388 pswp->hwndInsertBehind = hwndAfter;
1389 pswp->hwnd = hwnd;
1390
1391 ret = 0xf;
1392 }
1393adjustend:
1394 //The next part needs to be done for top-level windows only
1395 if(!((win32wnd->getStyle() & (WS_POPUP_W|WS_CHILD_W)) == WS_CHILD_W))
1396 {
1397 //Setting these flags is necessary to avoid activation/focus problems
1398 if(ulFlags & SWP_DEACTIVATE) {
1399 ret |= AWP_DEACTIVATE;
1400 }
1401 if(ulFlags & SWP_ACTIVATE)
1402 {
1403 if(ulFlags & SWP_ZORDER) {
1404 dprintf(("Set FF_NOACTIVATESWP"));
1405 ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
1406 WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags | FF_NOACTIVATESWP);
1407 }
1408
1409 if(!(ulFlags & SWP_SHOW))
1410 {
1411 ret |= AWP_ACTIVATE;
1412 }
1413 else
1414 {
1415 FrameSetFocus(hwnd);
1416 }
1417 }
1418 }
1419 else {
1420 if(ulFlags & (SWP_ACTIVATE|SWP_FOCUSACTIVATE))
1421 {
1422 win32wnd->MsgChildActivate(TRUE);
1423 if(fOS2Look) {
1424 dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
1425 WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
1426 }
1427 }
1428 else
1429 if(ulFlags & (SWP_DEACTIVATE|SWP_FOCUSDEACTIVATE))
1430 {
1431 win32wnd->MsgChildActivate(FALSE);
1432 if(fOS2Look) {
1433 dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
1434 WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
1435 }
1436 }
1437 }
1438 dprintf(("WM_ADJUSTWINDOWPOS ret %x flags %x", ret, WinQueryWindowUShort(hwnd, QWS_FLAGS)));
1439//testestset
1440 if(ret == 0x0f) {
1441 dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
1442 dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
1443 }
1444//testestset
1445 rc = (MRESULT)ret;
1446 break;
1447 }
1448
1449 case WM_WINDOWPOSCHANGED:
1450 {
1451 PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
1452 SWP swpOld = *(pswp + 1);
1453 WINDOWPOS wp;
1454 ULONG flAfp = (ULONG)mp2;
1455 HWND hParent = NULLHANDLE;
1456 RECTL rect;
1457
1458 dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%s) (%d,%d) (%d,%d) z %x", mp2, win32wnd->getWindowHandle(), pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy, Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind)));
1459 if(win32wnd->IsParentChanging()) {
1460 goto PosChangedEnd;
1461 }
1462
1463 //SvL: When a window is made visible, then we don't receive a
1464 // WM_VRNENABLED message (for some weird reason)
1465 if(pswp->fl & SWP_SHOW) {
1466 win32wnd->callVisibleRgnNotifyProc(TRUE);
1467 }
1468 else
1469 if(pswp->fl & SWP_HIDE) {
1470 win32wnd->callVisibleRgnNotifyProc(FALSE);
1471 }
1472
1473 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
1474 {
1475 if(pswp->fl & SWP_RESTORE && win32wnd->getStyle() & WS_MINIMIZE_W) {
1476 dprintf(("Restoring minimized window %x", win32wnd->getWindowHandle()));
1477 win32wnd->ShowWindow(SW_RESTORE_W);
1478 }
1479 if(pswp->fl & SWP_SHOW) {
1480 WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
1481 }
1482 else
1483 if(pswp->fl & SWP_HIDE) {
1484 WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
1485 }
1486 //MUST call the old frame window proc!
1487 goto RunDefFrameWndProc;
1488 }
1489
1490 if(pswp->fl & (SWP_MOVE | SWP_SIZE))
1491 {
1492 if(win32wnd->isChild())
1493 {
1494 if(win32wnd->getParent()) {
1495 hParent = win32wnd->getParent()->getOS2WindowHandle();
1496 }
1497 else goto PosChangedEnd; //parent has just been destroyed
1498 }
1499 }
1500
1501
1502 if(win32wnd->getParent()) {
1503 OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
1504 hwnd);
1505 }
1506 else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
1507
1508 wp.hwnd = win32wnd->getWindowHandle();
1509 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
1510 {
1511 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
1512 dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
1513 if(wndAfter) {
1514 wp.hwndInsertAfter = wndAfter->getWindowHandle();
1515 RELEASE_WNDOBJ(wndAfter);
1516 }
1517 else wp.hwndInsertAfter = HWND_TOP_W;
1518 }
1519
1520 if(pswp->fl & SWP_SHOW) {
1521 WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
1522 }
1523 else
1524 if(pswp->fl & SWP_HIDE) {
1525 WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
1526 }
1527
1528 if(flAfp & AWP_ACTIVATE)
1529 {
1530 FrameSetFocus(hwnd);
1531 }
1532
1533#ifndef USE_CALCVALIDRECT
1534 if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
1535 {
1536 //CB: todo: use result for WM_CALCVALIDRECTS
1537 //Get old client rectangle (for invalidation of frame window parts later on)
1538 //Use new window height to calculate the client area
1539 mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
1540
1541 //Note: Also updates the new window rectangle
1542 win32wnd->MsgFormatFrame(&wp);
1543
1544 if(win32wnd->isOwnDC()) {
1545 setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
1546 }
1547
1548 if(win32wnd->CanReceiveSizeMsgs())
1549 win32wnd->MsgPosChanged((LPARAM)&wp);
1550
1551 if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
1552 {
1553 //redraw the frame (to prevent unnecessary client updates)
1554 BOOL redrawAll = FALSE;
1555
1556 dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
1557 if (win32wnd->getWindowClass())
1558 {
1559 DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
1560
1561 if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
1562 redrawAll = TRUE;
1563 else
1564 if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
1565 redrawAll = TRUE;
1566 }
1567 else redrawAll = TRUE;
1568
1569 if(win32wnd->IsMixMaxStateChanging()) {
1570 dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
1571 redrawAll = TRUE;
1572 }
1573
1574 if (redrawAll)
1575 {
1576 //CB: redraw all children for now
1577 // -> problems with update region if we don't do it
1578 // todo: rewrite whole handling
1579 WinInvalidateRect(hwnd,NULL,TRUE);
1580 }
1581 else
1582 {
1583 HPS hps = WinGetPS(hwnd);
1584 RECTL frame,client,arcl[4];
1585
1586 WinQueryWindowRect(hwnd,&frame);
1587
1588 //top
1589 arcl[0].xLeft = 0;
1590 arcl[0].xRight = frame.xRight;
1591 arcl[0].yBottom = rect.yTop;
1592 arcl[0].yTop = frame.yTop;
1593 //right
1594 arcl[1].xLeft = rect.xRight;
1595 arcl[1].xRight = frame.xRight;
1596 arcl[1].yBottom = 0;
1597 arcl[1].yTop = frame.yTop;
1598 //left
1599 arcl[2].xLeft = 0;
1600 arcl[2].xRight = rect.xLeft;
1601 arcl[2].yBottom = 0;
1602 arcl[2].yTop = frame.yTop;
1603 //bottom
1604 arcl[3].xLeft = 0;
1605 arcl[3].xRight = frame.xRight;
1606 arcl[3].yBottom = 0;
1607 arcl[3].yTop = rect.yBottom;
1608
1609 HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
1610
1611 WinInvalidateRegion(hwnd,hrgn,FALSE);
1612 GpiDestroyRegion(hps,hrgn);
1613 WinReleasePS(hps);
1614 }
1615 }
1616 }
1617 else
1618 {
1619#endif //USE_CALCVALIDRECT
1620 if(win32wnd->CanReceiveSizeMsgs())
1621 win32wnd->MsgPosChanged((LPARAM)&wp);
1622#ifndef USE_CALCVALIDRECT
1623 }
1624#endif
1625
1626PosChangedEnd:
1627 rc = (MRESULT)FALSE;
1628 break;
1629 }
1630
1631 case WM_CALCVALIDRECTS:
1632#ifdef USE_CALCVALIDRECT
1633 {
1634 PRECTL oldRect = (PRECTL)mp1, newRect = oldRect+1;
1635 PSWP pswp = (PSWP)mp2;
1636 SWP swpOld;
1637 WINDOWPOS wp;
1638 RECTL newClientRect, oldClientRect;
1639 ULONG nccalcret;
1640// UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
1641 UINT res = 0;
1642
1643 dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
1644
1645 //Get old position info
1646 WinQueryWindowPos(hwnd, &swpOld);
1647
1648 if(win32wnd->getParent()) {
1649 OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
1650 win32wnd->getParent()->getClientRectPtr()->left,
1651 win32wnd->getParent()->getClientRectPtr()->top,
1652 hwnd);
1653 }
1654 else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
1655
1656 wp.hwnd = win32wnd->getWindowHandle();
1657 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
1658 {
1659 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
1660 if(wndAfter) {
1661 wp.hwndInsertAfter = wndAfter->getWindowHandle();
1662 RELEASE_WNDOBJ(wndAfter);
1663 }
1664 else wp.hwndInsertAfter = HWND_TOP_W;
1665 }
1666
1667 //Get old client rectangle
1668 mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
1669
1670 //Note: Also updates the new window rectangle
1671 nccalcret = win32wnd->MsgFormatFrame(&wp);
1672
1673 //Get new client rectangle
1674 mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
1675
1676 if(nccalcret == 0) {
1677 res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
1678 }
1679 else {
1680 if(nccalcret & WVR_ALIGNTOP_W) {
1681 res |= CVR_ALIGNTOP;
1682 }
1683 else
1684 if(nccalcret & WVR_ALIGNBOTTOM_W) {
1685 res |= CVR_ALIGNBOTTOM;
1686 }
1687
1688 if(nccalcret & WVR_ALIGNLEFT_W) {
1689 res |= CVR_ALIGNLEFT;
1690 }
1691 else
1692 if(nccalcret & WVR_ALIGNRIGHT_W) {
1693 res |= CVR_ALIGNRIGHT;
1694 }
1695
1696 if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
1697 res |= CVR_REDRAW;
1698 }
1699 else
1700 if(nccalcret & WVR_VALIDRECTS_W) {
1701 //TODO:
1702 //res = 0;
1703 }
1704 }
1705 if(win32wnd->IsMixMaxStateChanging()) {
1706 dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
1707 res |= CVR_REDRAW;
1708 }
1709 if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
1710 oldRect->xRight -= oldClientRect.xLeft;
1711 oldRect->yBottom += oldClientRect.yBottom;
1712 newRect->xRight -= newClientRect.xLeft;
1713 newRect->yBottom += newClientRect.yBottom;
1714 }
1715 rc = res;
1716 break;
1717 }
1718#else
1719 dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
1720 rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
1721 break;
1722#endif
1723
1724 case WM_CALCFRAMERECT:
1725 dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
1726 rc = (MRESULT)TRUE;
1727 break;
1728
1729 case WM_QUERYCTLTYPE:
1730 // This is a frame window
1731 dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
1732 rc = (MRESULT)CCT_FRAME;
1733 break;
1734
1735#ifdef DEBUG
1736 case WM_QUERYFOCUSCHAIN:
1737 dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x (%s) parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), DbgPrintQFCFlags(SHORT1FROMMP(mp1)), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0));
1738
1739 RestoreOS2TIB();
1740 rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
1741 SetWin32TIB();
1742 dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0, (rc) ? OS2ToWin32Handle((DWORD)rc) : 0));
1743 break;
1744// goto RunDefFrameWndProc;
1745#endif
1746
1747 case WM_FOCUSCHANGE:
1748 {
1749 HWND hwndFocus = (HWND)mp1;
1750 HWND hwndLoseFocus, hwndGainFocus;
1751 USHORT usSetFocus = SHORT1FROMMP(mp2);
1752 USHORT fsFocusChange = SHORT2FROMMP(mp2);
1753
1754 //Save window that gains focus so we can determine which
1755 //process we lose activation to
1756 hwndFocusChange = (HWND)mp1;
1757
1758 dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x (%x) %x %x", win32wnd->getWindowHandle(), OS2ToWin32Handle(hwndFocus), hwndFocus, usSetFocus, fsFocusChange));
1759 goto RunDefFrameWndProc;
1760 }
1761
1762#ifdef DEBUG
1763 case WM_SETFOCUS:
1764 {
1765 dprintf(("PMFRAME: WM_SETFOCUS %x %x", win32wnd->getWindowHandle(), hwnd));
1766 goto RunDefFrameWndProc;
1767 }
1768#endif
1769
1770 case WM_ACTIVATE:
1771 {
1772 HWND hwndTitle;
1773 USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
1774
1775 dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle((DWORD)mp2)));
1776 if (win32wnd->IsWindowCreated())
1777 {
1778 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
1779 if(fOS2Look) {
1780 dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
1781 WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, mp1, 0);
1782 }
1783 if(SHORT1FROMMP(mp1) == 0) {
1784 //deactivate
1785 WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
1786 }
1787 PID pidThis, pidPartner, pidTemp;
1788 TID tidPartner;
1789 HENUM henum;
1790 HWND hwndEnum;
1791
1792 WinQueryWindowProcess(hwnd, &pidThis, NULL);
1793 WinQueryWindowProcess(hwndFocusChange, &pidPartner, &tidPartner);
1794
1795 if(pidThis != pidPartner) {
1796 //Gain or lose activation to window in other process
1797 //must send WM_ACTIVATEAPP to top-level windows
1798
1799 //Iterate over all child windows of the desktop
1800 henum = WinBeginEnumWindows(HWND_DESKTOP);
1801
1802 while(hwndEnum = WinGetNextWindow(henum))
1803 {
1804 WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
1805 if(pidTemp == pidThis)
1806 {
1807 SendMessageA(OS2ToWin32Handle(hwndEnum), WM_ACTIVATEAPP_W, (WPARAM)SHORT1FROMMP(mp1), (LPARAM)tidPartner);
1808 }
1809 }
1810 WinEndEnumWindows(henum);
1811 }
1812 if(SHORT1FROMMP(mp1)) {
1813 //activate
1814 WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
1815 }
1816
1817 //CB: show owner behind the dialog
1818 if (win32wnd->IsModalDialog())
1819 {
1820 if(win32wnd->getOwner()) {
1821 Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
1822
1823 if (topOwner) {
1824 WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
1825 RELEASE_WNDOBJ(topOwner);
1826 }
1827 }
1828 }
1829 }
1830 else
1831 {
1832 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
1833 }
1834 rc = 0;
1835 break;
1836 }
1837
1838 case WM_ENABLE:
1839 dprintf(("PMFRAME: WM_ENABLE %x", hwnd));
1840 win32wnd->MsgEnable(SHORT1FROMMP(mp1));
1841 break;
1842
1843 case WM_SHOW:
1844 dprintf(("PMFRAME: WM_SHOW %x %d", hwnd, mp1));
1845 //show client window
1846 WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
1847 break;
1848
1849 case WM_QUERYTRACKINFO:
1850 {
1851 PTRACKINFO trackInfo = (PTRACKINFO)mp2;
1852
1853 dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
1854 trackInfo->cxBorder = 4;
1855 trackInfo->cyBorder = 4;
1856 win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
1857 rc = (MRESULT)TRUE;
1858 break;
1859 }
1860
1861 case WM_QUERYBORDERSIZE:
1862 {
1863 PWPOINT size = (PWPOINT)mp1;
1864
1865 dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
1866
1867 size->x = 0;
1868 size->y = 0;
1869 rc = (MRESULT)TRUE;
1870 break;
1871 }
1872
1873#ifdef DEBUG
1874 case WM_QUERYFRAMEINFO:
1875 dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
1876 goto RunDefFrameWndProc;
1877#endif
1878
1879 case WM_FORMATFRAME:
1880 dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
1881 break;
1882
1883 case WM_ADJUSTFRAMEPOS:
1884 {
1885 PSWP pswp = (PSWP)mp1;
1886
1887 dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
1888 //hack alert: the PM frame control changes the z-order of a child window
1889 // if it receives focus after a window has been destroyed
1890 // We can't let this happen as this messes up assumptions
1891 // elsewhere (e.g. GetNextDlgGroupItem)
1892 // By returning 0 here, we prevent the default frame handler
1893 // from messing things up. (one example is a group of radio buttons)
1894 //NOTE: We really need to get rid of frame & client windows for each
1895 // win32 window
1896 if(pswp->fl == SWP_FOCUSACTIVATE && win32wnd->isChild()) {
1897 rc = 0;
1898 break;
1899 }
1900 goto RunDefFrameWndProc;
1901 }
1902
1903#ifdef DEBUG
1904 case WM_OWNERPOSCHANGE:
1905 {
1906 PSWP pswp = (PSWP)mp1;
1907
1908 dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
1909 goto RunDefFrameWndProc;
1910 }
1911#endif
1912
1913 case WM_MINMAXFRAME:
1914 {
1915 PSWP swp = (PSWP)mp1;
1916
1917 if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
1918
1919 dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
1920 if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
1921 {
1922 win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
1923
1924 RECT rect;
1925
1926 rect.left = rect.top = rect.right = rect.bottom = 0;
1927 win32wnd->AdjustMaximizedRect(&rect);
1928 swp->x += rect.left;
1929 swp->cx += rect.right-rect.left;
1930 swp->y -= rect.bottom;
1931 swp->cy += rect.bottom-rect.top;
1932 }
1933 else
1934 if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
1935 {
1936 win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
1937 }
1938 else
1939 if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
1940 {
1941 win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
1942 }
1943 goto RunDefWndProc;
1944 }
1945
1946#ifdef DEBUG
1947 case WM_UPDATEFRAME:
1948 dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
1949 goto RunDefFrameWndProc;
1950#endif
1951
1952 case WM_TRACKFRAME:
1953 dprintf(("PMFRAME: WM_TRACKFRAME %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
1954 if(fOS2Look) {//sent by titlebar control
1955 Frame_SysCommandSizeMove(win32wnd, SC_MOVE_W+HTCAPTION_W);
1956 }
1957 rc = 0;
1958 break;
1959
1960 case WM_SYSCOMMAND:
1961 dprintf(("PMFRAME: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
1962 if (fOS2Look == OS2_APPEARANCE_SYSMENU && mp1 == (MPARAM)OSSC_SYSMENU)
1963 goto RunDefFrameWndProc;
1964
1965 if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
1966 RELEASE_WNDOBJ(win32wnd);
1967 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
1968 }
1969 if(win32wnd)
1970 win32wnd->DispatchMsgA(pWinMsg);
1971 break;
1972
1973#ifdef DEBUG
1974 case WM_DDE_INITIATE:
1975 case WM_DDE_INITIATEACK:
1976 case WM_DDE_REQUEST:
1977 case WM_DDE_ACK:
1978 case WM_DDE_DATA:
1979 case WM_DDE_ADVISE:
1980 case WM_DDE_UNADVISE:
1981 case WM_DDE_POKE:
1982 case WM_DDE_EXECUTE:
1983 case WM_DDE_TERMINATE:
1984 dprintf(("PMFRAME: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
1985 break;
1986#endif
1987
1988 default:
1989 goto RunDefFrameWndProc;
1990 }
1991 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
1992 RestoreOS2TIB();
1993
1994#ifdef DEBUG
1995 dbg_ThreadPopCall();
1996#endif
1997 return (MRESULT)rc;
1998
1999RunDefFrameWndProc:
2000 dprintf2(("RunDefFrameWndProc"));
2001 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
2002 RestoreOS2TIB();
2003
2004#ifdef DEBUG
2005 dbg_ThreadPopCall();
2006#endif
2007 return pfnFrameWndProc(hwnd, msg, mp1, mp2);
2008
2009RunDefWndProc:
2010 dprintf2(("RunDefWndProc"));
2011 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
2012 RestoreOS2TIB();
2013 //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
2014// return pfnFrameWndProc(hwnd, msg, mp1, mp2);
2015
2016#ifdef DEBUG
2017 dbg_ThreadPopCall();
2018#endif
2019 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
2020}
2021//******************************************************************************
2022//******************************************************************************
2023void FrameSetFocus(HWND hwnd)
2024{
2025 HWND hwndFocusSave = WinQueryWindowULong(hwnd, QWL_HWNDFOCUSSAVE);
2026 if(!WinIsWindow(hab, hwndFocusSave)) {
2027 hwndFocusSave = WinWindowFromID(hwnd, FID_CLIENT);
2028 WinSetWindowULong(hwnd, QWL_HWNDFOCUSSAVE, hwndFocusSave);
2029 }
2030 dprintf(("FrameSetFocus: hwndFocusSave %x %x", OS2ToWin32Handle(hwndFocusSave), hwndFocusSave));
2031 WinSetFocus(HWND_DESKTOP, hwndFocusSave);
2032
2033 ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
2034 ulFrameFlags &= ~FF_NOACTIVATESWP;
2035 WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags);
2036}
2037//******************************************************************************
2038//******************************************************************************
2039void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
2040 HBITMAP hbmNew)
2041{
2042 MENUITEM mi;
2043
2044 if (!hwndMenu)
2045 return;
2046
2047 WinEnableWindowUpdate(hwndMenu, FALSE);
2048
2049 if (WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(idOld, TRUE), MPFROMP(&mi)))
2050 {
2051 WinSendMsg(hwndMenu, MM_REMOVEITEM, (MPARAM)idOld, 0);
2052 mi.afStyle = MIS_BITMAP | MIS_SYSCOMMAND;
2053 mi.afAttribute = 0;
2054 mi.hwndSubMenu = 0;
2055 mi.id = idNew;
2056 mi.hItem = (ULONG)hbmNew;
2057 WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, 0);
2058 }
2059 WinEnableWindowUpdate(hwndMenu, TRUE);
2060
2061 WinInvalidateRect(hwndMenu, NULL, TRUE);
2062}
2063//******************************************************************************
2064//******************************************************************************
2065static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes)
2066{
2067 PDRAGITEM pDragItem;
2068 int i, cItems;
2069 BOOL ret;
2070 char szFileName[CCHMAXPATH];
2071 char szContainerName[CCHMAXPATH];
2072 ULONG ulBytes;
2073 char *pszCurFile = NULL;
2074
2075 /* Get access to the DRAGINFO data structure */
2076 if(!DrgAccessDraginfo(pDragInfo)) {
2077 return NULL;
2078 }
2079
2080 cItems = DrgQueryDragitemCount(pDragInfo);
2081
2082 //computer memory required to hold all filenames
2083 int bufsize = 0;
2084 for (i = 0; i < cItems; i++) {
2085 pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
2086
2087 bufsize += DrgQueryStrNameLen(pDragItem->hstrContainerName) + DrgQueryStrNameLen(pDragItem->hstrSourceName);
2088 bufsize++; //0 terminator
2089 bufsize++; //+ potential missing backslash
2090 }
2091 bufsize++; //extra 0 terminator
2092 char *pszFiles = (char *)malloc(bufsize);
2093 if(pszFiles == NULL) {
2094 dprintf(("Out of memory!!"));
2095 DebugInt3();
2096 goto failure;
2097 }
2098 memset(pszFiles, 0, bufsize);
2099
2100 pszCurFile = pszFiles;
2101
2102 //copy all filenames
2103 for (i = 0; i < cItems; i++) {
2104 char *pszTemp = pszCurFile;
2105
2106 pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
2107
2108 ulBytes = DrgQueryStrNameLen(pDragItem->hstrContainerName);
2109 ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
2110 ulBytes, pszCurFile);
2111 if(pszCurFile[ulBytes-1] != '\\') {
2112 pszCurFile[ulBytes] = '\\';
2113 pszCurFile++;
2114 }
2115 pszCurFile += ulBytes;
2116
2117 ulBytes = DrgQueryStrNameLen(pDragItem->hstrSourceName);
2118 ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
2119 ulBytes+1, pszCurFile);
2120 pszCurFile += ulBytes + 1; //+ terminator
2121
2122 dprintf(("dropped file %s", pszTemp));
2123 }
2124
2125 /* Release the draginfo data structure */
2126 DrgFreeDraginfo(pDragInfo);
2127
2128 *pulBytes = bufsize;
2129 *pcItems = cItems;
2130
2131 return pszFiles;
2132
2133failure:
2134 /* Release the draginfo data structure */
2135 DrgFreeDraginfo(pDragInfo);
2136 if(pszFiles) {
2137 free(pszFiles);
2138 }
2139 return NULL;
2140}
2141//******************************************************************************
2142//******************************************************************************
2143static BOOL PMDragValidate(PDRAGINFO pDragInfo)
2144{
2145 PDRAGITEM pDragItem;
2146 ULONG ulBytes;
2147 int i, cItems;
2148 BOOL ret;
2149 char szFileName[CCHMAXPATH];
2150 char szContainerName[CCHMAXPATH];
2151 USHORT usOp = DO_MOVE;
2152
2153 /* Get access to the DRAGINFO data structure */
2154 if(!DrgAccessDraginfo(pDragInfo)) {
2155 return FALSE;
2156 }
2157
2158 /* Can we accept this drop? */
2159 switch (pDragInfo->usOperation) {
2160 /* Return DOR_NODROPOP if current operation */
2161 /* is link or unknown */
2162 case DO_LINK:
2163 case DO_COPY:
2164 case DO_UNKNOWN:
2165 goto failure;
2166
2167 /* Our default operation is Move */
2168 case DO_MOVE:
2169 case DO_DEFAULT:
2170 pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
2171 ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
2172 sizeof(szContainerName),
2173 szContainerName);
2174 ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
2175 sizeof(szFileName),
2176 szFileName);
2177 if (!ulBytes) {
2178 goto failure;
2179 }
2180
2181 dprintf(("dropped file %s%s", szContainerName, szFileName));
2182 break;
2183 }
2184
2185 cItems = DrgQueryDragitemCount(pDragInfo);
2186
2187 /* Now, we need to look at each item in turn */
2188 for (i = 0; i < cItems; i++) {
2189 pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
2190
2191 /* Make sure we can move for a Move request */
2192 if (!((pDragItem->fsSupportedOps & DO_MOVEABLE) &&
2193 (usOp == (USHORT)DO_MOVE)))
2194 {
2195 dprintf(("item %d not accepted", i));
2196 goto failure;
2197 }
2198 }
2199 /* Release the draginfo data structure */
2200 DrgFreeDraginfo(pDragInfo);
2201 return TRUE;
2202
2203failure:
2204 DrgFreeDraginfo(pDragInfo);
2205 return FALSE;
2206}
2207//******************************************************************************
2208//******************************************************************************
2209#ifdef DEBUG
2210static char *DbgGetStringSWPFlags(ULONG flags)
2211{
2212 static char szSWPFlags[512];
2213
2214 szSWPFlags[0] = 0;
2215
2216 if(flags & SWP_SIZE) {
2217 strcat(szSWPFlags, "SWP_SIZE ");
2218 }
2219 if(flags & SWP_MOVE) {
2220 strcat(szSWPFlags, "SWP_MOVE ");
2221 }
2222 if(flags & SWP_ZORDER) {
2223 strcat(szSWPFlags, "SWP_ZORDER ");
2224 }
2225 if(flags & SWP_SHOW) {
2226 strcat(szSWPFlags, "SWP_SHOW ");
2227 }
2228 if(flags & SWP_HIDE) {
2229 strcat(szSWPFlags, "SWP_HIDE ");
2230 }
2231 if(flags & SWP_NOREDRAW) {
2232 strcat(szSWPFlags, "SWP_NOREDRAW ");
2233 }
2234 if(flags & SWP_NOADJUST) {
2235 strcat(szSWPFlags, "SWP_NOADJUST ");
2236 }
2237 if(flags & SWP_ACTIVATE) {
2238 strcat(szSWPFlags, "SWP_ACTIVATE ");
2239 }
2240 if(flags & SWP_DEACTIVATE) {
2241 strcat(szSWPFlags, "SWP_DEACTIVATE ");
2242 }
2243 if(flags & SWP_EXTSTATECHANGE) {
2244 strcat(szSWPFlags, "SWP_EXTSTATECHANGE ");
2245 }
2246 if(flags & SWP_MINIMIZE) {
2247 strcat(szSWPFlags, "SWP_MINIMIZE ");
2248 }
2249 if(flags & SWP_MAXIMIZE) {
2250 strcat(szSWPFlags, "SWP_MAXIMIZE ");
2251 }
2252 if(flags & SWP_RESTORE) {
2253 strcat(szSWPFlags, "SWP_RESTORE ");
2254 }
2255 if(flags & SWP_FOCUSACTIVATE) {
2256 strcat(szSWPFlags, "SWP_FOCUSACTIVATE ");
2257 }
2258 if(flags & SWP_FOCUSDEACTIVATE) {
2259 strcat(szSWPFlags, "SWP_FOCUSDEACTIVATE ");
2260 }
2261 if(flags & SWP_NOAUTOCLOSE) {
2262 strcat(szSWPFlags, "SWP_NOAUTOCLOSE ");
2263 }
2264 return szSWPFlags;
2265}
2266static char *DbgPrintQFCFlags(ULONG flags)
2267{
2268 static char szQFCFlags[64];
2269
2270 szQFCFlags[0] = 0;
2271
2272 if(flags & QFC_NEXTINCHAIN) {
2273 strcat(szQFCFlags, "QFC_NEXTINCHAIN");
2274 }
2275 else
2276 if(flags & QFC_ACTIVE) {
2277 strcat(szQFCFlags, "QFC_ACTIVE");
2278 }
2279 else
2280 if(flags & QFC_FRAME) {
2281 strcat(szQFCFlags, "QFC_FRAME");
2282 }
2283 else
2284 if(flags & QFC_SELECTACTIVE) {
2285 strcat(szQFCFlags, "QFC_SELECTACTIVE");
2286 }
2287 else
2288 if(flags & QFC_PARTOFCHAIN) {
2289 strcat(szQFCFlags, "QFC_PARTOFCHAIN");
2290 }
2291
2292 return szQFCFlags;
2293}
2294#endif
2295//******************************************************************************
2296//******************************************************************************
Note: See TracBrowser for help on using the repository browser.