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

Last change on this file since 21543 was 21543, checked in by dmik, 15 years ago

user32: Do not change the code page of the main PM thread as Odin may be attached to a foreign process (such as Firefox through the Flash plugin) which will not expect the code page change (see #24).

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