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

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