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

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

CopyBitmap fix + use PM bitmaps for standard user32 frame buttons in OS/2 GUI mode

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