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

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

When a window is activated by a mouse click, we must set focus to the client window (and not the frame..)

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