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

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

Check if WM_KILLFOCUS was already sent by SetFocus(0) call

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