1 | /* $Id: pmwindow.cpp,v 1.201 2003-02-27 14:22:43 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 |
|
---|
64 | HMQ hmq = 0; /* Message queue handle */
|
---|
65 | HAB hab = 0;
|
---|
66 | RECTL desktopRectl = {0};
|
---|
67 | ULONG ScreenWidth = 0;
|
---|
68 | ULONG ScreenHeight = 0;
|
---|
69 | ULONG ScreenBitsPerPel = 0;
|
---|
70 | BOOL fOS2Look = FALSE;
|
---|
71 | BOOL fForceMonoCursor = FALSE;
|
---|
72 | BOOL fDragDropActive = FALSE;
|
---|
73 | BOOL 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 |
|
---|
85 | HBITMAP hbmFrameMenu[8] = {0};
|
---|
86 |
|
---|
87 | //Win32 bitmap handles of the OS/2 min, max and restore buttons
|
---|
88 | HBITMAP hBmpMinButton = 0;
|
---|
89 | HBITMAP hBmpMaxButton = 0;
|
---|
90 | HBITMAP hBmpRestoreButton = 0;
|
---|
91 | HBITMAP hBmpCloseButton = 0;
|
---|
92 | HBITMAP hBmpMinButtonDown = 0;
|
---|
93 | HBITMAP hBmpMaxButtonDown = 0;
|
---|
94 | HBITMAP hBmpRestoreButtonDown = 0;
|
---|
95 | HBITMAP hBmpCloseButtonDown = 0;
|
---|
96 |
|
---|
97 | static PFNWP pfnFrameWndProc = NULL;
|
---|
98 | static 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
|
---|
103 | LONG 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.
|
---|
109 | static BOOL fKeyAltGrDown = FALSE;
|
---|
110 |
|
---|
111 |
|
---|
112 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes);
|
---|
113 | static BOOL PMDragValidate(PDRAGINFO pDragInfo);
|
---|
114 | static void QueryPMMenuBitmaps();
|
---|
115 |
|
---|
116 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
117 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
118 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
119 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
---|
120 | HBITMAP hbmNew);
|
---|
121 | void FrameSetFocus(HWND hwnd);
|
---|
122 |
|
---|
123 | VOID APIENTRY DspInitSystemDriverName(PSZ pszDriverName, ULONG lenDriverName);
|
---|
124 |
|
---|
125 | #ifdef DEBUG
|
---|
126 | static char *DbgGetStringSWPFlags(ULONG flags);
|
---|
127 | static 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 | //******************************************************************************
|
---|
137 | BOOL 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 | //******************************************************************************
|
---|
260 | HBITMAP OPEN32API _O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap);
|
---|
261 |
|
---|
262 | inline 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 | //******************************************************************************
|
---|
273 | static 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 | //******************************************************************************
|
---|
315 | void 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 | //******************************************************************************
|
---|
327 | void WIN32API CustForceMonoCursor()
|
---|
328 | {
|
---|
329 | fForceMonoCursor = TRUE;
|
---|
330 | }
|
---|
331 | //******************************************************************************
|
---|
332 | //******************************************************************************
|
---|
333 | void WIN32API DisableDragDrop(BOOL fDisabled)
|
---|
334 | {
|
---|
335 | fDragDropDisabled = fDisabled;
|
---|
336 | }
|
---|
337 | //******************************************************************************
|
---|
338 | //CD notification window class
|
---|
339 | //******************************************************************************
|
---|
340 | MRESULT 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 | //******************************************************************************
|
---|
479 | MRESULT 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 WIN32APP_CHNGEFRAMECTRLS:
|
---|
710 | {
|
---|
711 | dprintf(("OS2: WIN32APP_CHANGEFRAMECTRLS"));
|
---|
712 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), (ULONG)mp1, win32wnd->getExStyle(), (ULONG)mp2);
|
---|
713 | break;
|
---|
714 | }
|
---|
715 |
|
---|
716 | case WM_SETFOCUS:
|
---|
717 | {
|
---|
718 | HWND hwndFocus = (HWND)mp1;
|
---|
719 |
|
---|
720 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
|
---|
721 |
|
---|
722 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
---|
723 | //must delay this function call
|
---|
724 |
|
---|
725 | teb->o.odin.fWM_SETFOCUS = TRUE;
|
---|
726 | teb->o.odin.hwndFocus = 0;
|
---|
727 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
|
---|
728 | {
|
---|
729 | //another (non-win32) application's window
|
---|
730 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
---|
731 | hwndFocus = NULL;
|
---|
732 | }
|
---|
733 | if((ULONG)mp2 == TRUE) {
|
---|
734 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
---|
735 | recreateCaret (hwndFocusWin32);
|
---|
736 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
---|
737 | }
|
---|
738 | else {
|
---|
739 | //If SetFocus(0) was called, then the window has already received
|
---|
740 | //a WM_KILLFOCUS; don't send another one
|
---|
741 | if(!fIgnoreKeystrokes) {
|
---|
742 | win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
---|
743 | }
|
---|
744 | else dprintf(("Window has already received a WM_KILLFOCUS (SetFocus(0)); ignore"));
|
---|
745 | }
|
---|
746 | teb->o.odin.fWM_SETFOCUS = FALSE;
|
---|
747 |
|
---|
748 | break;
|
---|
749 | }
|
---|
750 |
|
---|
751 | //**************************************************************************
|
---|
752 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
753 | //**************************************************************************
|
---|
754 |
|
---|
755 | case WM_BUTTON1DOWN:
|
---|
756 | case WM_BUTTON1UP:
|
---|
757 | case WM_BUTTON1DBLCLK:
|
---|
758 | case WM_BUTTON2DOWN:
|
---|
759 | case WM_BUTTON2UP:
|
---|
760 | case WM_BUTTON2DBLCLK:
|
---|
761 | case WM_BUTTON3DOWN:
|
---|
762 | case WM_BUTTON3UP:
|
---|
763 | case WM_BUTTON3DBLCLK:
|
---|
764 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
765 | RELEASE_WNDOBJ(win32wnd);
|
---|
766 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
767 | }
|
---|
768 | if(win32wnd)
|
---|
769 | win32wnd->MsgButton(pWinMsg);
|
---|
770 |
|
---|
771 | rc = (MRESULT)TRUE;
|
---|
772 | break;
|
---|
773 |
|
---|
774 | case WM_BUTTON2MOTIONSTART:
|
---|
775 | case WM_BUTTON2MOTIONEND:
|
---|
776 | case WM_BUTTON2CLICK:
|
---|
777 | case WM_BUTTON1MOTIONSTART:
|
---|
778 | case WM_BUTTON1MOTIONEND:
|
---|
779 | case WM_BUTTON1CLICK:
|
---|
780 | case WM_BUTTON3MOTIONSTART:
|
---|
781 | case WM_BUTTON3MOTIONEND:
|
---|
782 | case WM_BUTTON3CLICK:
|
---|
783 | rc = (MRESULT)TRUE;
|
---|
784 | break;
|
---|
785 |
|
---|
786 | case WM_MOUSEMOVE:
|
---|
787 | {
|
---|
788 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
789 | RELEASE_WNDOBJ(win32wnd);
|
---|
790 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
791 | }
|
---|
792 | if(win32wnd)
|
---|
793 | win32wnd->MsgMouseMove(pWinMsg);
|
---|
794 | break;
|
---|
795 | }
|
---|
796 |
|
---|
797 | case WM_CONTROL:
|
---|
798 | goto RunDefWndProc;
|
---|
799 |
|
---|
800 | case WM_COMMAND:
|
---|
801 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
---|
802 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
803 | break;
|
---|
804 |
|
---|
805 | case WM_SYSCOMMAND:
|
---|
806 | dprintf(("OS2: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
807 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
808 | break;
|
---|
809 |
|
---|
810 | case WM_RENDERFMT:
|
---|
811 | case WM_RENDERALLFMTS:
|
---|
812 | case WM_DESTROYCLIPBOARD:
|
---|
813 | case WM_DRAWCLIPBOARD:
|
---|
814 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
815 | break;
|
---|
816 |
|
---|
817 | case WM_CHAR_SPECIAL:
|
---|
818 | /* NO BREAK! FALLTHRU CASE! */
|
---|
819 |
|
---|
820 | case WM_CHAR:
|
---|
821 | dprintf(("OS2: WM_CHAR %x %x %x, %x %x focus wnd %x", win32wnd->getWindowHandle(), mp1, mp2, pWinMsg->wParam, pWinMsg->lParam, WinQueryFocus(HWND_DESKTOP)));
|
---|
822 | win32wnd->MsgChar(pWinMsg);
|
---|
823 | break;
|
---|
824 |
|
---|
825 | case WM_TIMER:
|
---|
826 | dprintf(("OS2: WM_TIMER %x %x time %x", win32wnd->getWindowHandle(), pWinMsg->wParam, GetTickCount()));
|
---|
827 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
828 | goto RunDefWndProc;
|
---|
829 |
|
---|
830 | case WM_SETWINDOWPARAMS:
|
---|
831 | {
|
---|
832 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
---|
833 |
|
---|
834 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
---|
835 | if(wndParams->fsStatus & WPM_TEXT) {
|
---|
836 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
---|
837 | }
|
---|
838 | goto RunDefWndProc;
|
---|
839 | }
|
---|
840 |
|
---|
841 | case WM_QUERYWINDOWPARAMS:
|
---|
842 | {
|
---|
843 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
---|
844 | ULONG textlen;
|
---|
845 | PSZ wintext;
|
---|
846 |
|
---|
847 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
---|
848 | {
|
---|
849 | if(wndpars->fsStatus & WPM_TEXT)
|
---|
850 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
---|
851 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
---|
852 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
---|
853 |
|
---|
854 | wndpars->fsStatus = 0;
|
---|
855 | wndpars->cbCtlData = 0;
|
---|
856 | wndpars->cbPresParams = 0;
|
---|
857 | rc = (MRESULT)TRUE;
|
---|
858 | break;
|
---|
859 | }
|
---|
860 | goto RunDefWndProc;
|
---|
861 | }
|
---|
862 |
|
---|
863 | case WM_PAINT:
|
---|
864 | {
|
---|
865 | RECTL rectl;
|
---|
866 | BOOL rc;
|
---|
867 |
|
---|
868 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
---|
869 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
---|
870 |
|
---|
871 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
---|
872 | rectl.yBottom != rectl.yTop) && !IsIconic(win32wnd->GetTopParent()))
|
---|
873 | {
|
---|
874 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
875 | }
|
---|
876 | else goto RunDefWndProc;
|
---|
877 | break;
|
---|
878 | }
|
---|
879 |
|
---|
880 | case WM_ERASEBACKGROUND:
|
---|
881 | {
|
---|
882 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
---|
883 | rc = (MRESULT)FALSE;
|
---|
884 | break;
|
---|
885 | }
|
---|
886 |
|
---|
887 | case WM_CALCVALIDRECTS:
|
---|
888 | dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
889 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
---|
890 | break;
|
---|
891 |
|
---|
892 | case WM_REALIZEPALETTE:
|
---|
893 | {
|
---|
894 | dprintf(("OS2: WM_REALIZEPALETTE %x", win32wnd->getWindowHandle()));
|
---|
895 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
896 | break;
|
---|
897 | }
|
---|
898 |
|
---|
899 | case WM_HSCROLL:
|
---|
900 | case WM_VSCROLL:
|
---|
901 | dprintf(("OS2: %s %x %x %x", (msg == WM_HSCROLL) ? "WM_HSCROLL" : "WM_VSCROLL", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
902 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
903 | break;
|
---|
904 |
|
---|
905 | case DM_DRAGOVER:
|
---|
906 | {
|
---|
907 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
---|
908 | PDRAGITEM pDragItem;
|
---|
909 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
---|
910 | USHORT syDrop = SHORT2FROMMP(mp2);
|
---|
911 |
|
---|
912 | dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
---|
913 |
|
---|
914 | if(fDragDropDisabled) {
|
---|
915 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
916 | break;
|
---|
917 | }
|
---|
918 |
|
---|
919 | //does this window accept dropped files?
|
---|
920 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
---|
921 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
922 | break;
|
---|
923 | }
|
---|
924 |
|
---|
925 | if(PMDragValidate(pDragInfo) == FALSE) {
|
---|
926 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
927 | break;
|
---|
928 | }
|
---|
929 | if(win32wnd->isDragDropActive() == FALSE) {
|
---|
930 | ULONG ulBytes, cItems;
|
---|
931 | char *pszFiles;
|
---|
932 |
|
---|
933 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
---|
934 | if(pszFiles) {
|
---|
935 | POINT point = {sxDrop, syDrop};
|
---|
936 | if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) {
|
---|
937 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
938 | }
|
---|
939 | else {
|
---|
940 | fDragDropActive = TRUE;
|
---|
941 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
---|
942 | win32wnd->setDragDropActive(TRUE);
|
---|
943 | }
|
---|
944 | free(pszFiles);
|
---|
945 | }
|
---|
946 | else {
|
---|
947 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
948 | }
|
---|
949 | }
|
---|
950 | else {
|
---|
951 | if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) {
|
---|
952 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
953 | }
|
---|
954 | else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
---|
955 | }
|
---|
956 | break;
|
---|
957 | }
|
---|
958 |
|
---|
959 | case DM_DRAGLEAVE:
|
---|
960 | {
|
---|
961 | dprintf(("OS2: DM_DRAGLEAVE %x", win32wnd->getWindowHandle()));
|
---|
962 |
|
---|
963 | if(fDragDropDisabled) {
|
---|
964 | break;
|
---|
965 | }
|
---|
966 |
|
---|
967 | fDragDropActive = FALSE;
|
---|
968 |
|
---|
969 | //does this window accept dropped files?
|
---|
970 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
---|
971 | break;
|
---|
972 | }
|
---|
973 |
|
---|
974 | DragDropDragLeave(win32wnd->getWindowHandle());
|
---|
975 | win32wnd->setDragDropActive(FALSE);
|
---|
976 | break;
|
---|
977 | }
|
---|
978 |
|
---|
979 | case DM_DROP:
|
---|
980 | {
|
---|
981 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
---|
982 | PDRAGITEM pDragItem;
|
---|
983 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
---|
984 | USHORT syDrop = SHORT2FROMMP(mp2);
|
---|
985 | USHORT usIndicator, usOp;
|
---|
986 |
|
---|
987 | dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
---|
988 |
|
---|
989 | fDragDropActive = FALSE;
|
---|
990 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
---|
991 |
|
---|
992 | if(fDragDropDisabled) {
|
---|
993 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
---|
994 | break;
|
---|
995 | }
|
---|
996 |
|
---|
997 | //does this window accept dropped files?
|
---|
998 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
---|
999 | break;
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | ULONG ulBytes, cItems;
|
---|
1003 | char *pszFiles;
|
---|
1004 |
|
---|
1005 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
---|
1006 | if(pszFiles) {
|
---|
1007 | POINT point = {sxDrop, syDrop};
|
---|
1008 | if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) {
|
---|
1009 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
1010 | }
|
---|
1011 | else {
|
---|
1012 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
---|
1013 | win32wnd->setDragDropActive(FALSE);
|
---|
1014 | }
|
---|
1015 | free(pszFiles);
|
---|
1016 | }
|
---|
1017 | else {
|
---|
1018 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
---|
1019 | }
|
---|
1020 | break;
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | case WM_DDE_INITIATE:
|
---|
1024 | case WM_DDE_INITIATEACK:
|
---|
1025 | case WM_DDE_REQUEST:
|
---|
1026 | case WM_DDE_ACK:
|
---|
1027 | case WM_DDE_DATA:
|
---|
1028 | case WM_DDE_ADVISE:
|
---|
1029 | case WM_DDE_UNADVISE:
|
---|
1030 | case WM_DDE_POKE:
|
---|
1031 | case WM_DDE_EXECUTE:
|
---|
1032 | case WM_DDE_TERMINATE:
|
---|
1033 | dprintf(("OS2: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
---|
1034 | goto RunDefWndProc;
|
---|
1035 |
|
---|
1036 | case WM_INITMENU:
|
---|
1037 | case WM_MENUSELECT:
|
---|
1038 | case WM_MENUEND:
|
---|
1039 | case WM_NEXTMENU:
|
---|
1040 | case WM_SYSCOLORCHANGE:
|
---|
1041 | case WM_SYSVALUECHANGED:
|
---|
1042 | case WM_SETSELECTION:
|
---|
1043 | case WM_PPAINT:
|
---|
1044 | case WM_PSETFOCUS:
|
---|
1045 | case WM_PSYSCOLORCHANGE:
|
---|
1046 | case WM_PSIZE:
|
---|
1047 | case WM_PACTIVATE:
|
---|
1048 | case WM_PCONTROL:
|
---|
1049 | case WM_HELP:
|
---|
1050 | case WM_APPTERMINATENOTIFY:
|
---|
1051 | case WM_PRESPARAMCHANGED:
|
---|
1052 | case WM_DRAWITEM:
|
---|
1053 | case WM_MEASUREITEM:
|
---|
1054 | case WM_CONTROLPOINTER:
|
---|
1055 | case WM_QUERYDLGCODE:
|
---|
1056 | case WM_SUBSTITUTESTRING:
|
---|
1057 | case WM_MATCHMNEMONIC:
|
---|
1058 | case WM_SAVEAPPLICATION:
|
---|
1059 | case WM_SEMANTICEVENT:
|
---|
1060 | default:
|
---|
1061 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
---|
1062 | goto RunDefWndProc;
|
---|
1063 | }
|
---|
1064 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
1065 | RestoreOS2TIB();
|
---|
1066 |
|
---|
1067 | #ifdef DEBUG
|
---|
1068 | dbg_ThreadPopCall();
|
---|
1069 | #endif
|
---|
1070 | return (MRESULT)rc;
|
---|
1071 |
|
---|
1072 | RunDefWndProc:
|
---|
1073 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
---|
1074 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
1075 | RestoreOS2TIB();
|
---|
1076 |
|
---|
1077 | #ifdef DEBUG
|
---|
1078 | dbg_ThreadPopCall();
|
---|
1079 | #endif
|
---|
1080 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
1081 | } /* End of Win32WindowProc */
|
---|
1082 | //******************************************************************************
|
---|
1083 | //******************************************************************************
|
---|
1084 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1085 | {
|
---|
1086 | POSTMSG_PACKET *postmsg;
|
---|
1087 | OSLIBPOINT point, ClientPoint;
|
---|
1088 | Win32BaseWindow *win32wnd;
|
---|
1089 | TEB *teb;
|
---|
1090 | MRESULT rc = 0;
|
---|
1091 | MSG winMsg, *pWinMsg;
|
---|
1092 |
|
---|
1093 | #ifdef DEBUG
|
---|
1094 | dbg_ThreadPushCall("Win32FrameWindowProc");
|
---|
1095 | #endif
|
---|
1096 |
|
---|
1097 | //Restore our FS selector
|
---|
1098 | SetWin32TIB();
|
---|
1099 |
|
---|
1100 | // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
---|
1101 | teb = GetThreadTEB();
|
---|
1102 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
---|
1103 |
|
---|
1104 | // do some sanity checking here:
|
---|
1105 | // - we need to have a TEB handle
|
---|
1106 | // - unless this is WM_CREATE (the very first message), there has to be
|
---|
1107 | // a USER32 window object for this window handle
|
---|
1108 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
---|
1109 | dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
---|
1110 | goto RunDefFrameWndProc;
|
---|
1111 | }
|
---|
1112 | //// if(teb->o.odin.fIgnoreMsgs) {
|
---|
1113 | //// goto RunDefWndProc;
|
---|
1114 | //// }
|
---|
1115 |
|
---|
1116 | // check if the message state counter in the TEB is odd
|
---|
1117 | // This means the message has been sent directly from PM to our message
|
---|
1118 | // handler (so it is the first time we know about this PM message).
|
---|
1119 | // If this is the case, we have to translate it here to a Win32
|
---|
1120 | // message first. The other case is that the message is the result of a
|
---|
1121 | // WinDispatchMsg call and therefore has already been translated.
|
---|
1122 | if((teb->o.odin.msgstate & 1) == 0)
|
---|
1123 | {//message that was sent directly to our window proc handler; translate it here
|
---|
1124 | QMSG qmsg;
|
---|
1125 |
|
---|
1126 | qmsg.msg = msg;
|
---|
1127 | qmsg.hwnd = hwnd;
|
---|
1128 | qmsg.mp1 = mp1;
|
---|
1129 | qmsg.mp2 = mp2;
|
---|
1130 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
---|
1131 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
---|
1132 | qmsg.reserved = 0;
|
---|
1133 |
|
---|
1134 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
---|
1135 | {//message was not translated
|
---|
1136 | memset(&winMsg, 0, sizeof(MSG));
|
---|
1137 | }
|
---|
1138 | pWinMsg = &winMsg;
|
---|
1139 | }
|
---|
1140 | else {
|
---|
1141 | // message has already been translated before (GetMessage/PeekMessage).
|
---|
1142 | // Use the translated information. Flip the translation flag.
|
---|
1143 | pWinMsg = &teb->o.odin.msg;
|
---|
1144 | teb->o.odin.msgstate++;
|
---|
1145 | }
|
---|
1146 | // END NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
---|
1147 |
|
---|
1148 | switch( msg )
|
---|
1149 | {
|
---|
1150 | case WM_CREATE:
|
---|
1151 | {
|
---|
1152 | //WM_CREATE handled during client window creation
|
---|
1153 | dprintf(("PMFRAME: WM_CREATE %x", hwnd));
|
---|
1154 | goto RunDefFrameWndProc;
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | //hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
|
---|
1158 | // handler; must postpone it, so do it here
|
---|
1159 | case WIN32APP_POSTPONEDESTROY:
|
---|
1160 | OSLibWinDestroyWindow(hwnd);
|
---|
1161 | break;
|
---|
1162 | //hack end
|
---|
1163 |
|
---|
1164 | #ifdef DEBUG
|
---|
1165 | case WM_CLOSE:
|
---|
1166 | {
|
---|
1167 | dprintf(("PMFRAME: WM_CLOSE %x", hwnd));
|
---|
1168 | goto RunDefFrameWndProc;
|
---|
1169 | }
|
---|
1170 | #endif
|
---|
1171 |
|
---|
1172 | case WM_PAINT:
|
---|
1173 | {
|
---|
1174 | RECTL rectl;
|
---|
1175 |
|
---|
1176 | HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
|
---|
1177 | dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
---|
1178 |
|
---|
1179 | if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
---|
1180 | rectl.yBottom != rectl.yTop))
|
---|
1181 | {
|
---|
1182 | PRECT pClient = win32wnd->getClientRectPtr();
|
---|
1183 | PRECT pWindow = win32wnd->getWindowRect();
|
---|
1184 |
|
---|
1185 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
---|
1186 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
---|
1187 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
---|
1188 | {
|
---|
1189 | RECT rectUpdate;
|
---|
1190 |
|
---|
1191 | mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
|
---|
1192 | win32wnd->MsgNCPaint(&rectUpdate);
|
---|
1193 | }
|
---|
1194 | }
|
---|
1195 | WinEndPaint(hps);
|
---|
1196 | break;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | case WM_ERASEBACKGROUND:
|
---|
1200 | {
|
---|
1201 | dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
---|
1202 | rc = (MRESULT)FALSE;
|
---|
1203 | break;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | //**************************************************************************
|
---|
1207 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
1208 | //**************************************************************************
|
---|
1209 |
|
---|
1210 | case WM_BUTTON1DOWN:
|
---|
1211 | case WM_BUTTON1UP:
|
---|
1212 | case WM_BUTTON1DBLCLK:
|
---|
1213 | case WM_BUTTON2DOWN:
|
---|
1214 | case WM_BUTTON2UP:
|
---|
1215 | case WM_BUTTON2DBLCLK:
|
---|
1216 | case WM_BUTTON3DOWN:
|
---|
1217 | case WM_BUTTON3UP:
|
---|
1218 | case WM_BUTTON3DBLCLK:
|
---|
1219 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
1220 | RELEASE_WNDOBJ(win32wnd);
|
---|
1221 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
1222 | }
|
---|
1223 | if(win32wnd)
|
---|
1224 | win32wnd->MsgButton(pWinMsg);
|
---|
1225 |
|
---|
1226 | rc = (MRESULT)TRUE;
|
---|
1227 | break;
|
---|
1228 |
|
---|
1229 | case WM_BUTTON2MOTIONSTART:
|
---|
1230 | case WM_BUTTON2MOTIONEND:
|
---|
1231 | case WM_BUTTON2CLICK:
|
---|
1232 | case WM_BUTTON1MOTIONSTART:
|
---|
1233 | case WM_BUTTON1MOTIONEND:
|
---|
1234 | case WM_BUTTON1CLICK:
|
---|
1235 | case WM_BUTTON3MOTIONSTART:
|
---|
1236 | case WM_BUTTON3MOTIONEND:
|
---|
1237 | case WM_BUTTON3CLICK:
|
---|
1238 | rc = (MRESULT)TRUE;
|
---|
1239 | break;
|
---|
1240 |
|
---|
1241 | case WM_MOUSEMOVE:
|
---|
1242 | {
|
---|
1243 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
1244 | RELEASE_WNDOBJ(win32wnd);
|
---|
1245 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
1246 | }
|
---|
1247 | if(win32wnd)
|
---|
1248 | win32wnd->MsgMouseMove(pWinMsg);
|
---|
1249 | break;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | case WM_ADJUSTWINDOWPOS:
|
---|
1253 | {
|
---|
1254 | PSWP pswp = (PSWP)mp1;
|
---|
1255 | SWP swpOld;
|
---|
1256 | WINDOWPOS wp,wpOld;
|
---|
1257 | ULONG ulFlags;
|
---|
1258 | ULONG ret = 0;
|
---|
1259 | HWND hParent = NULLHANDLE, hwndAfter;
|
---|
1260 |
|
---|
1261 | 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));
|
---|
1262 |
|
---|
1263 | ulFlags = pswp->fl;
|
---|
1264 |
|
---|
1265 | if(win32wnd->IsParentChanging()) {
|
---|
1266 | rc = 0;
|
---|
1267 | break;
|
---|
1268 | }
|
---|
1269 |
|
---|
1270 | //@@PF all commands from minimized window viewer or from Ctrl-Esc
|
---|
1271 | //are 'pure' and should be handled only by DeFrameProc - this is weird
|
---|
1272 | //but without them we will not have results. Pure = plain flag of restore/minimize/maximize
|
---|
1273 | if((pswp->fl == SWP_MINIMIZE) || (pswp->fl & SWP_RESTORE)) {
|
---|
1274 | // note the purity of SWP no other SWP_FLAGS allowed
|
---|
1275 | goto RunDefFrameWndProc;
|
---|
1276 | }
|
---|
1277 |
|
---|
1278 | if(pswp->fl & SWP_NOADJUST) {
|
---|
1279 | //ignore weird messages (TODO: why are they sent?)
|
---|
1280 | dprintf(("WARNING: WM_ADJUSTWINDOWPOS with SWP_NOADJUST flag!!"));
|
---|
1281 | break;
|
---|
1282 | }
|
---|
1283 | if ((pswp->fl == SWP_FOCUSACTIVATE) || (pswp->fl == SWP_FOCUSDEACTIVATE))
|
---|
1284 | {
|
---|
1285 | dprintf(("Pure focus flags are not sent to win32 windows"));
|
---|
1286 | goto RunDefFrameWndProc;
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | //CB: show dialog in front of owner
|
---|
1290 | if (win32wnd->IsModalDialogOwner())
|
---|
1291 | {
|
---|
1292 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
---|
1293 | pswp->fl |= SWP_ZORDER;
|
---|
1294 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
---|
1295 | if (pswp->fl & SWP_ACTIVATE)
|
---|
1296 | {
|
---|
1297 | pswp->fl &= ~SWP_ACTIVATE;
|
---|
1298 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
---|
1299 | }
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | if(!win32wnd->CanReceiveSizeMsgs())
|
---|
1303 | break;
|
---|
1304 |
|
---|
1305 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
1306 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
1307 | if (win32wnd->isChild()) {
|
---|
1308 | if(win32wnd->getParent()) {
|
---|
1309 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
1310 | }
|
---|
1311 | else goto RunDefFrameWndProc;
|
---|
1312 | }
|
---|
1313 | }
|
---|
1314 | hwndAfter = pswp->hwndInsertBehind;
|
---|
1315 | if(win32wnd->getParent()) {
|
---|
1316 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
|
---|
1317 | }
|
---|
1318 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1319 |
|
---|
1320 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1321 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1322 | {
|
---|
1323 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1324 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
---|
1325 | if(wndAfter) {
|
---|
1326 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1327 | RELEASE_WNDOBJ(wndAfter);
|
---|
1328 | }
|
---|
1329 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | wpOld = wp;
|
---|
1333 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
---|
1334 |
|
---|
1335 | if(win32wnd->getOldStyle() != win32wnd->getStyle())
|
---|
1336 | {
|
---|
1337 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), win32wnd->getStyle(), win32wnd->getExStyle(), win32wnd->getStyle());
|
---|
1338 | if(fOS2Look) {
|
---|
1339 | DWORD dwOldStyle = win32wnd->getOldStyle();
|
---|
1340 | DWORD dwStyle = win32wnd->getStyle();
|
---|
1341 |
|
---|
1342 | win32wnd->setOldStyle(dwStyle);
|
---|
1343 | if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
|
---|
1344 | //SC_RESTORE -> SC_MINIMIZE
|
---|
1345 | dprintf(("%x -> SC_RESTORE -> SC_MINIMIZE", win32wnd->getWindowHandle()));
|
---|
1346 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_RESTORE, SC_MINIMIZE, hbmFrameMenu[PMMENU_MINBUTTON]);
|
---|
1347 | if(dwStyle & WS_MAXIMIZE_W) {
|
---|
1348 | //SC_MAXIMIZE -> SC_RESTORE
|
---|
1349 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (1)", win32wnd->getWindowHandle()));
|
---|
1350 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
---|
1351 | }
|
---|
1352 | }
|
---|
1353 | else
|
---|
1354 | if((dwOldStyle & WS_MAXIMIZE_W) && !(dwStyle & WS_MAXIMIZE_W)) {
|
---|
1355 | //SC_RESTORE -> SC_MAXIMIZE
|
---|
1356 | dprintf(("%x -> SC_RESTORE -> SC_MAXIMIZE", win32wnd->getWindowHandle()));
|
---|
1357 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_RESTORE, SC_MAXIMIZE, hbmFrameMenu[PMMENU_MAXBUTTON]);
|
---|
1358 | }
|
---|
1359 | else
|
---|
1360 | if(!(dwOldStyle & WS_MINIMIZE_W) && (dwStyle & WS_MINIMIZE_W)) {
|
---|
1361 | //SC_MINIMIZE -> SC_RESTORE
|
---|
1362 | dprintf(("%x -> SC_MINIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
|
---|
1363 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_MINIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
---|
1364 | }
|
---|
1365 | else
|
---|
1366 | if(!(dwOldStyle & WS_MAXIMIZE_W) && (dwStyle & WS_MAXIMIZE_W)) {
|
---|
1367 | //SC_MAXIMIZE -> SC_RESTORE
|
---|
1368 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (2)", win32wnd->getWindowHandle()));
|
---|
1369 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
---|
1370 | }
|
---|
1371 | }
|
---|
1372 | }
|
---|
1373 |
|
---|
1374 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
---|
1375 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
---|
1376 | {
|
---|
1377 | ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
|
---|
1378 |
|
---|
1379 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
---|
1380 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1381 |
|
---|
1382 | if(win32wnd->getParent()) {
|
---|
1383 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1384 | hwnd);
|
---|
1385 | }
|
---|
1386 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1387 |
|
---|
1388 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1389 |
|
---|
1390 | //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
|
---|
1391 | if(pswp->fl & SWP_SIZE)
|
---|
1392 | flags |= SWP_SIZE;
|
---|
1393 |
|
---|
1394 | if(pswp->fl & SWP_MOVE)
|
---|
1395 | flags |= SWP_MOVE;
|
---|
1396 |
|
---|
1397 | pswp->fl = flags; //restore flags
|
---|
1398 |
|
---|
1399 | pswp->fl |= SWP_NOADJUST;
|
---|
1400 | pswp->hwndInsertBehind = hwndAfter;
|
---|
1401 | pswp->hwnd = hwnd;
|
---|
1402 |
|
---|
1403 | ret = 0xf;
|
---|
1404 | }
|
---|
1405 | adjustend:
|
---|
1406 | //The next part needs to be done for top-level windows only
|
---|
1407 | if(!((win32wnd->getStyle() & (WS_POPUP_W|WS_CHILD_W)) == WS_CHILD_W))
|
---|
1408 | {
|
---|
1409 | //Setting these flags is necessary to avoid activation/focus problems
|
---|
1410 | if(ulFlags & SWP_DEACTIVATE) {
|
---|
1411 | ret |= AWP_DEACTIVATE;
|
---|
1412 | }
|
---|
1413 | if(ulFlags & SWP_ACTIVATE)
|
---|
1414 | {
|
---|
1415 | if(ulFlags & SWP_ZORDER) {
|
---|
1416 | dprintf(("Set FF_NOACTIVATESWP"));
|
---|
1417 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
---|
1418 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags | FF_NOACTIVATESWP);
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | if(!(ulFlags & SWP_SHOW))
|
---|
1422 | {
|
---|
1423 | ret |= AWP_ACTIVATE;
|
---|
1424 | }
|
---|
1425 | else
|
---|
1426 | {
|
---|
1427 | FrameSetFocus(hwnd);
|
---|
1428 | }
|
---|
1429 | }
|
---|
1430 | }
|
---|
1431 | else {
|
---|
1432 | if(ulFlags & (SWP_ACTIVATE|SWP_FOCUSACTIVATE))
|
---|
1433 | {
|
---|
1434 | win32wnd->MsgChildActivate(TRUE);
|
---|
1435 | if(fOS2Look) {
|
---|
1436 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1437 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
---|
1438 | }
|
---|
1439 | }
|
---|
1440 | else
|
---|
1441 | if(ulFlags & (SWP_DEACTIVATE|SWP_FOCUSDEACTIVATE))
|
---|
1442 | {
|
---|
1443 | win32wnd->MsgChildActivate(FALSE);
|
---|
1444 | if(fOS2Look) {
|
---|
1445 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1446 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
---|
1447 | }
|
---|
1448 | }
|
---|
1449 | }
|
---|
1450 | dprintf(("WM_ADJUSTWINDOWPOS ret %x flags %x", ret, WinQueryWindowUShort(hwnd, QWS_FLAGS)));
|
---|
1451 | //testestset
|
---|
1452 | if(ret == 0x0f) {
|
---|
1453 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
---|
1454 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1455 | }
|
---|
1456 | //testestset
|
---|
1457 | rc = (MRESULT)ret;
|
---|
1458 | break;
|
---|
1459 | }
|
---|
1460 |
|
---|
1461 | case WM_WINDOWPOSCHANGED:
|
---|
1462 | {
|
---|
1463 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
---|
1464 | SWP swpOld = *(pswp + 1);
|
---|
1465 | WINDOWPOS wp;
|
---|
1466 | ULONG flAfp = (ULONG)mp2;
|
---|
1467 | HWND hParent = NULLHANDLE;
|
---|
1468 | RECTL rect;
|
---|
1469 |
|
---|
1470 | 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)));
|
---|
1471 | if(win32wnd->IsParentChanging()) {
|
---|
1472 | goto PosChangedEnd;
|
---|
1473 | }
|
---|
1474 |
|
---|
1475 | //SvL: When a window is made visible, then we don't receive a
|
---|
1476 | // WM_VRNENABLED message (for some weird reason)
|
---|
1477 | if(pswp->fl & SWP_SHOW) {
|
---|
1478 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
---|
1479 | }
|
---|
1480 | else
|
---|
1481 | if(pswp->fl & SWP_HIDE) {
|
---|
1482 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
---|
1483 | }
|
---|
1484 |
|
---|
1485 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
---|
1486 | {
|
---|
1487 | if(pswp->fl & SWP_RESTORE && win32wnd->getStyle() & WS_MINIMIZE_W) {
|
---|
1488 | dprintf(("Restoring minimized window %x", win32wnd->getWindowHandle()));
|
---|
1489 | win32wnd->ShowWindow(SW_RESTORE_W);
|
---|
1490 | }
|
---|
1491 | if(pswp->fl & SWP_SHOW) {
|
---|
1492 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
---|
1493 | }
|
---|
1494 | else
|
---|
1495 | if(pswp->fl & SWP_HIDE) {
|
---|
1496 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
---|
1497 | }
|
---|
1498 | //MUST call the old frame window proc!
|
---|
1499 | goto RunDefFrameWndProc;
|
---|
1500 | }
|
---|
1501 |
|
---|
1502 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
---|
1503 | {
|
---|
1504 | if(win32wnd->isChild())
|
---|
1505 | {
|
---|
1506 | if(win32wnd->getParent()) {
|
---|
1507 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
1508 | }
|
---|
1509 | else goto PosChangedEnd; //parent has just been destroyed
|
---|
1510 | }
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 |
|
---|
1514 | if(win32wnd->getParent()) {
|
---|
1515 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1516 | hwnd);
|
---|
1517 | }
|
---|
1518 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1519 |
|
---|
1520 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1521 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1522 | {
|
---|
1523 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1524 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
---|
1525 | if(wndAfter) {
|
---|
1526 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1527 | RELEASE_WNDOBJ(wndAfter);
|
---|
1528 | }
|
---|
1529 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | if(pswp->fl & SWP_SHOW) {
|
---|
1533 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
---|
1534 | }
|
---|
1535 | else
|
---|
1536 | if(pswp->fl & SWP_HIDE) {
|
---|
1537 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
---|
1538 | }
|
---|
1539 |
|
---|
1540 | if(flAfp & AWP_ACTIVATE)
|
---|
1541 | {
|
---|
1542 | FrameSetFocus(hwnd);
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | #ifndef USE_CALCVALIDRECT
|
---|
1546 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
|
---|
1547 | {
|
---|
1548 | //CB: todo: use result for WM_CALCVALIDRECTS
|
---|
1549 | //Get old client rectangle (for invalidation of frame window parts later on)
|
---|
1550 | //Use new window height to calculate the client area
|
---|
1551 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
---|
1552 |
|
---|
1553 | //Note: Also updates the new window rectangle
|
---|
1554 | win32wnd->MsgFormatFrame(&wp);
|
---|
1555 |
|
---|
1556 | if(win32wnd->isOwnDC()) {
|
---|
1557 | setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
|
---|
1558 | }
|
---|
1559 |
|
---|
1560 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
1561 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
1562 |
|
---|
1563 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
---|
1564 | {
|
---|
1565 | //redraw the frame (to prevent unnecessary client updates)
|
---|
1566 | BOOL redrawAll = FALSE;
|
---|
1567 |
|
---|
1568 | dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
|
---|
1569 | if (win32wnd->getWindowClass())
|
---|
1570 | {
|
---|
1571 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
---|
1572 |
|
---|
1573 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
---|
1574 | redrawAll = TRUE;
|
---|
1575 | else
|
---|
1576 | if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
---|
1577 | redrawAll = TRUE;
|
---|
1578 | }
|
---|
1579 | else redrawAll = TRUE;
|
---|
1580 |
|
---|
1581 | if(win32wnd->IsMixMaxStateChanging()) {
|
---|
1582 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
---|
1583 | redrawAll = TRUE;
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | if (redrawAll)
|
---|
1587 | {
|
---|
1588 | //CB: redraw all children for now
|
---|
1589 | // -> problems with update region if we don't do it
|
---|
1590 | // todo: rewrite whole handling
|
---|
1591 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED invalidate all"));
|
---|
1592 | WinInvalidateRect(hwnd,NULL,TRUE);
|
---|
1593 | }
|
---|
1594 | else
|
---|
1595 | {
|
---|
1596 | HPS hps = WinGetPS(hwnd);
|
---|
1597 | RECTL frame,client,arcl[4];
|
---|
1598 |
|
---|
1599 | WinQueryWindowRect(hwnd,&frame);
|
---|
1600 |
|
---|
1601 | //top
|
---|
1602 | arcl[0].xLeft = 0;
|
---|
1603 | arcl[0].xRight = frame.xRight;
|
---|
1604 | arcl[0].yBottom = rect.yTop;
|
---|
1605 | arcl[0].yTop = frame.yTop;
|
---|
1606 | //right
|
---|
1607 | arcl[1].xLeft = rect.xRight;
|
---|
1608 | arcl[1].xRight = frame.xRight;
|
---|
1609 | arcl[1].yBottom = 0;
|
---|
1610 | arcl[1].yTop = frame.yTop;
|
---|
1611 | //left
|
---|
1612 | arcl[2].xLeft = 0;
|
---|
1613 | arcl[2].xRight = rect.xLeft;
|
---|
1614 | arcl[2].yBottom = 0;
|
---|
1615 | arcl[2].yTop = frame.yTop;
|
---|
1616 | //bottom
|
---|
1617 | arcl[3].xLeft = 0;
|
---|
1618 | arcl[3].xRight = frame.xRight;
|
---|
1619 | arcl[3].yBottom = 0;
|
---|
1620 | arcl[3].yTop = rect.yBottom;
|
---|
1621 |
|
---|
1622 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
---|
1623 |
|
---|
1624 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
---|
1625 | GpiDestroyRegion(hps,hrgn);
|
---|
1626 | WinReleasePS(hps);
|
---|
1627 | }
|
---|
1628 | }
|
---|
1629 | }
|
---|
1630 | else
|
---|
1631 | {
|
---|
1632 | #endif //USE_CALCVALIDRECT
|
---|
1633 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
1634 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
1635 | #ifndef USE_CALCVALIDRECT
|
---|
1636 | }
|
---|
1637 | #endif
|
---|
1638 |
|
---|
1639 | PosChangedEnd:
|
---|
1640 | rc = (MRESULT)FALSE;
|
---|
1641 | break;
|
---|
1642 | }
|
---|
1643 |
|
---|
1644 | case WM_CALCVALIDRECTS:
|
---|
1645 | #ifdef USE_CALCVALIDRECT
|
---|
1646 | {
|
---|
1647 | PRECTL oldRect = (PRECTL)mp1, newRect = oldRect+1;
|
---|
1648 | PSWP pswp = (PSWP)mp2;
|
---|
1649 | SWP swpOld;
|
---|
1650 | WINDOWPOS wp;
|
---|
1651 | RECTL newClientRect, oldClientRect;
|
---|
1652 | ULONG nccalcret;
|
---|
1653 | // UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
---|
1654 | UINT res = 0;
|
---|
1655 |
|
---|
1656 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
1657 |
|
---|
1658 | //Get old position info
|
---|
1659 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
1660 |
|
---|
1661 | if(win32wnd->getParent()) {
|
---|
1662 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1663 | win32wnd->getParent()->getClientRectPtr()->left,
|
---|
1664 | win32wnd->getParent()->getClientRectPtr()->top,
|
---|
1665 | hwnd);
|
---|
1666 | }
|
---|
1667 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
---|
1668 |
|
---|
1669 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1670 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1671 | {
|
---|
1672 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1673 | if(wndAfter) {
|
---|
1674 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1675 | RELEASE_WNDOBJ(wndAfter);
|
---|
1676 | }
|
---|
1677 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | //Get old client rectangle
|
---|
1681 | mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
|
---|
1682 |
|
---|
1683 | //Note: Also updates the new window rectangle
|
---|
1684 | nccalcret = win32wnd->MsgFormatFrame(&wp);
|
---|
1685 |
|
---|
1686 | //Get new client rectangle
|
---|
1687 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
|
---|
1688 |
|
---|
1689 | if(nccalcret == 0) {
|
---|
1690 | res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
|
---|
1691 | }
|
---|
1692 | else {
|
---|
1693 | if(nccalcret & WVR_ALIGNTOP_W) {
|
---|
1694 | res |= CVR_ALIGNTOP;
|
---|
1695 | }
|
---|
1696 | else
|
---|
1697 | if(nccalcret & WVR_ALIGNBOTTOM_W) {
|
---|
1698 | res |= CVR_ALIGNBOTTOM;
|
---|
1699 | }
|
---|
1700 |
|
---|
1701 | if(nccalcret & WVR_ALIGNLEFT_W) {
|
---|
1702 | res |= CVR_ALIGNLEFT;
|
---|
1703 | }
|
---|
1704 | else
|
---|
1705 | if(nccalcret & WVR_ALIGNRIGHT_W) {
|
---|
1706 | res |= CVR_ALIGNRIGHT;
|
---|
1707 | }
|
---|
1708 |
|
---|
1709 | if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
|
---|
1710 | res |= CVR_REDRAW;
|
---|
1711 | }
|
---|
1712 | else
|
---|
1713 | if(nccalcret & WVR_VALIDRECTS_W) {
|
---|
1714 | //TODO:
|
---|
1715 | //res = 0;
|
---|
1716 | }
|
---|
1717 | }
|
---|
1718 | if(win32wnd->IsMixMaxStateChanging()) {
|
---|
1719 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
---|
1720 | res |= CVR_REDRAW;
|
---|
1721 | }
|
---|
1722 | if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
|
---|
1723 | oldRect->xRight -= oldClientRect.xLeft;
|
---|
1724 | oldRect->yBottom += oldClientRect.yBottom;
|
---|
1725 | newRect->xRight -= newClientRect.xLeft;
|
---|
1726 | newRect->yBottom += newClientRect.yBottom;
|
---|
1727 | }
|
---|
1728 | rc = res;
|
---|
1729 | break;
|
---|
1730 | }
|
---|
1731 | #else
|
---|
1732 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
1733 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
---|
1734 | break;
|
---|
1735 | #endif
|
---|
1736 |
|
---|
1737 | case WM_CALCFRAMERECT:
|
---|
1738 | dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
---|
1739 | rc = (MRESULT)TRUE;
|
---|
1740 | break;
|
---|
1741 |
|
---|
1742 | case WM_QUERYCTLTYPE:
|
---|
1743 | // This is a frame window
|
---|
1744 | dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
---|
1745 | rc = (MRESULT)CCT_FRAME;
|
---|
1746 | break;
|
---|
1747 |
|
---|
1748 | #ifdef DEBUG
|
---|
1749 | case WM_QUERYFOCUSCHAIN:
|
---|
1750 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x (%s) parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), DbgPrintQFCFlags(SHORT1FROMMP(mp1)), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0));
|
---|
1751 |
|
---|
1752 | RestoreOS2TIB();
|
---|
1753 | rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
1754 | SetWin32TIB();
|
---|
1755 | 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));
|
---|
1756 | break;
|
---|
1757 | // goto RunDefFrameWndProc;
|
---|
1758 | #endif
|
---|
1759 |
|
---|
1760 | case WM_FOCUSCHANGE:
|
---|
1761 | {
|
---|
1762 | HWND hwndFocus = (HWND)mp1;
|
---|
1763 | HWND hwndLoseFocus, hwndGainFocus;
|
---|
1764 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
---|
1765 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
---|
1766 |
|
---|
1767 | //Save window that gains focus so we can determine which
|
---|
1768 | //process we lose activation to
|
---|
1769 | hwndFocusChange = (HWND)mp1;
|
---|
1770 |
|
---|
1771 | dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x (%x) %x %x", win32wnd->getWindowHandle(), OS2ToWin32Handle(hwndFocus), hwndFocus, usSetFocus, fsFocusChange));
|
---|
1772 | goto RunDefFrameWndProc;
|
---|
1773 | }
|
---|
1774 |
|
---|
1775 | #ifdef DEBUG
|
---|
1776 | case WM_SETFOCUS:
|
---|
1777 | {
|
---|
1778 | dprintf(("PMFRAME: WM_SETFOCUS %x %x %d -> %x", win32wnd->getWindowHandle(), hwnd, mp2, mp1));
|
---|
1779 | goto RunDefFrameWndProc;
|
---|
1780 | }
|
---|
1781 | #endif
|
---|
1782 |
|
---|
1783 | case WM_ACTIVATE:
|
---|
1784 | {
|
---|
1785 | HWND hwndTitle;
|
---|
1786 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
---|
1787 |
|
---|
1788 | dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle((DWORD)mp2)));
|
---|
1789 | if (win32wnd->IsWindowCreated())
|
---|
1790 | {
|
---|
1791 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
1792 | if(fOS2Look) {
|
---|
1793 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1794 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, mp1, 0);
|
---|
1795 | }
|
---|
1796 | if(SHORT1FROMMP(mp1) == 0) {
|
---|
1797 | //deactivate
|
---|
1798 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
---|
1799 | }
|
---|
1800 | PID pidThis, pidPartner, pidTemp;
|
---|
1801 | TID tidPartner;
|
---|
1802 | HENUM henum;
|
---|
1803 | HWND hwndEnum;
|
---|
1804 |
|
---|
1805 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
---|
1806 | WinQueryWindowProcess(hwndFocusChange, &pidPartner, &tidPartner);
|
---|
1807 |
|
---|
1808 | if(pidThis != pidPartner) {
|
---|
1809 | //Gain or lose activation to window in other process
|
---|
1810 | //must send WM_ACTIVATEAPP to top-level windows
|
---|
1811 |
|
---|
1812 | //Iterate over all child windows of the desktop
|
---|
1813 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
---|
1814 |
|
---|
1815 | while(hwndEnum = WinGetNextWindow(henum))
|
---|
1816 | {
|
---|
1817 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
---|
1818 | if(pidTemp == pidThis)
|
---|
1819 | {
|
---|
1820 | SendMessageA(OS2ToWin32Handle(hwndEnum), WM_ACTIVATEAPP_W, (WPARAM)SHORT1FROMMP(mp1), (LPARAM)tidPartner);
|
---|
1821 | }
|
---|
1822 | }
|
---|
1823 | WinEndEnumWindows(henum);
|
---|
1824 | }
|
---|
1825 | if(SHORT1FROMMP(mp1)) {
|
---|
1826 | //activate
|
---|
1827 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
---|
1828 | }
|
---|
1829 |
|
---|
1830 | //CB: show owner behind the dialog
|
---|
1831 | if (win32wnd->IsModalDialog())
|
---|
1832 | {
|
---|
1833 | if(win32wnd->getOwner()) {
|
---|
1834 | Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
|
---|
1835 |
|
---|
1836 | if (topOwner) {
|
---|
1837 | WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
---|
1838 | RELEASE_WNDOBJ(topOwner);
|
---|
1839 | }
|
---|
1840 | }
|
---|
1841 | }
|
---|
1842 | }
|
---|
1843 | else
|
---|
1844 | {
|
---|
1845 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
1846 | }
|
---|
1847 | rc = 0;
|
---|
1848 | break;
|
---|
1849 | }
|
---|
1850 |
|
---|
1851 | case WM_ENABLE:
|
---|
1852 | dprintf(("PMFRAME: WM_ENABLE %x", hwnd));
|
---|
1853 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
---|
1854 | break;
|
---|
1855 |
|
---|
1856 | case WM_SHOW:
|
---|
1857 | dprintf(("PMFRAME: WM_SHOW %x %d", hwnd, mp1));
|
---|
1858 | //show client window
|
---|
1859 | WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
|
---|
1860 | break;
|
---|
1861 |
|
---|
1862 | case WM_QUERYTRACKINFO:
|
---|
1863 | {
|
---|
1864 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
---|
1865 |
|
---|
1866 | dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
---|
1867 | trackInfo->cxBorder = 4;
|
---|
1868 | trackInfo->cyBorder = 4;
|
---|
1869 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
---|
1870 | rc = (MRESULT)TRUE;
|
---|
1871 | break;
|
---|
1872 | }
|
---|
1873 |
|
---|
1874 | case WM_QUERYBORDERSIZE:
|
---|
1875 | {
|
---|
1876 | PWPOINT size = (PWPOINT)mp1;
|
---|
1877 |
|
---|
1878 | dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
---|
1879 |
|
---|
1880 | size->x = 0;
|
---|
1881 | size->y = 0;
|
---|
1882 | rc = (MRESULT)TRUE;
|
---|
1883 | break;
|
---|
1884 | }
|
---|
1885 |
|
---|
1886 | #ifdef DEBUG
|
---|
1887 | case WM_QUERYFRAMEINFO:
|
---|
1888 | dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
---|
1889 | goto RunDefFrameWndProc;
|
---|
1890 | #endif
|
---|
1891 |
|
---|
1892 | case WM_FORMATFRAME:
|
---|
1893 | dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
---|
1894 | break;
|
---|
1895 |
|
---|
1896 | case WM_ADJUSTFRAMEPOS:
|
---|
1897 | {
|
---|
1898 | PSWP pswp = (PSWP)mp1;
|
---|
1899 |
|
---|
1900 | 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));
|
---|
1901 | //hack alert: the PM frame control changes the z-order of a child window
|
---|
1902 | // if it receives focus after a window has been destroyed
|
---|
1903 | // We can't let this happen as this messes up assumptions
|
---|
1904 | // elsewhere (e.g. GetNextDlgGroupItem)
|
---|
1905 | // By returning 0 here, we prevent the default frame handler
|
---|
1906 | // from messing things up. (one example is a group of radio buttons)
|
---|
1907 | //NOTE: We really need to get rid of frame & client windows for each
|
---|
1908 | // win32 window
|
---|
1909 | if(pswp->fl == SWP_FOCUSACTIVATE && win32wnd->isChild()) {
|
---|
1910 | rc = 0;
|
---|
1911 | break;
|
---|
1912 | }
|
---|
1913 | //hack alert: as we return zero as border size (check handler) we need
|
---|
1914 | //to do adjustments here as well or PM will calculate it for us and
|
---|
1915 | //result will be illegal. Btw we do not honour PM border size settings
|
---|
1916 | //and never will. I was unable to figure out why only X coordinate
|
---|
1917 | //is being broken but not Y as well.
|
---|
1918 |
|
---|
1919 | if ((pswp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
---|
1920 | {
|
---|
1921 | RECT rect;
|
---|
1922 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
---|
1923 | win32wnd->AdjustMaximizedRect(&rect);
|
---|
1924 |
|
---|
1925 | pswp->x += rect.left;
|
---|
1926 | }
|
---|
1927 | goto RunDefFrameWndProc;
|
---|
1928 | }
|
---|
1929 |
|
---|
1930 | #ifdef DEBUG
|
---|
1931 | case WM_OWNERPOSCHANGE:
|
---|
1932 | {
|
---|
1933 | PSWP pswp = (PSWP)mp1;
|
---|
1934 |
|
---|
1935 | 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));
|
---|
1936 | goto RunDefFrameWndProc;
|
---|
1937 | }
|
---|
1938 | #endif
|
---|
1939 |
|
---|
1940 | case WM_MINMAXFRAME:
|
---|
1941 | {
|
---|
1942 | PSWP swp = (PSWP)mp1;
|
---|
1943 |
|
---|
1944 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
---|
1945 |
|
---|
1946 | dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
|
---|
1947 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
---|
1948 | {
|
---|
1949 | RECT rect;
|
---|
1950 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
---|
1951 | win32wnd->AdjustMaximizedRect(&rect);
|
---|
1952 |
|
---|
1953 | swp->x += rect.left;
|
---|
1954 | swp->cx += rect.right-rect.left;
|
---|
1955 | swp->y -= rect.bottom;
|
---|
1956 | swp->cy += rect.bottom-rect.top;
|
---|
1957 |
|
---|
1958 | win32wnd->ShowWindow(SW_RESTORE_W);
|
---|
1959 | }
|
---|
1960 | else
|
---|
1961 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
---|
1962 | {
|
---|
1963 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
---|
1964 | }
|
---|
1965 | else
|
---|
1966 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
---|
1967 | {
|
---|
1968 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
---|
1969 | }
|
---|
1970 | goto RunDefWndProc;
|
---|
1971 | }
|
---|
1972 |
|
---|
1973 | #ifdef DEBUG
|
---|
1974 | case WM_UPDATEFRAME:
|
---|
1975 | dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
---|
1976 | goto RunDefFrameWndProc;
|
---|
1977 | #endif
|
---|
1978 |
|
---|
1979 | case WM_TRACKFRAME:
|
---|
1980 | dprintf(("PMFRAME: WM_TRACKFRAME %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
1981 | if(fOS2Look) {//sent by titlebar control
|
---|
1982 | Frame_SysCommandSizeMove(win32wnd, SC_MOVE_W+HTCAPTION_W);
|
---|
1983 | }
|
---|
1984 | rc = 0;
|
---|
1985 | break;
|
---|
1986 |
|
---|
1987 | case WM_SYSCOMMAND:
|
---|
1988 | dprintf(("PMFRAME: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
1989 | if (fOS2Look == OS2_APPEARANCE_SYSMENU && mp1 == (MPARAM)OSSC_SYSMENU)
|
---|
1990 | goto RunDefFrameWndProc;
|
---|
1991 |
|
---|
1992 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
1993 | RELEASE_WNDOBJ(win32wnd);
|
---|
1994 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
1995 | }
|
---|
1996 | if(win32wnd)
|
---|
1997 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
1998 | break;
|
---|
1999 |
|
---|
2000 | #ifdef DEBUG
|
---|
2001 | case WM_DDE_INITIATE:
|
---|
2002 | case WM_DDE_INITIATEACK:
|
---|
2003 | case WM_DDE_REQUEST:
|
---|
2004 | case WM_DDE_ACK:
|
---|
2005 | case WM_DDE_DATA:
|
---|
2006 | case WM_DDE_ADVISE:
|
---|
2007 | case WM_DDE_UNADVISE:
|
---|
2008 | case WM_DDE_POKE:
|
---|
2009 | case WM_DDE_EXECUTE:
|
---|
2010 | case WM_DDE_TERMINATE:
|
---|
2011 | dprintf(("PMFRAME: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
---|
2012 | break;
|
---|
2013 | #endif
|
---|
2014 |
|
---|
2015 | default:
|
---|
2016 | goto RunDefFrameWndProc;
|
---|
2017 | }
|
---|
2018 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
2019 | RestoreOS2TIB();
|
---|
2020 |
|
---|
2021 | #ifdef DEBUG
|
---|
2022 | dbg_ThreadPopCall();
|
---|
2023 | #endif
|
---|
2024 | return (MRESULT)rc;
|
---|
2025 |
|
---|
2026 | RunDefFrameWndProc:
|
---|
2027 | dprintf2(("RunDefFrameWndProc"));
|
---|
2028 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
2029 | RestoreOS2TIB();
|
---|
2030 |
|
---|
2031 | #ifdef DEBUG
|
---|
2032 | dbg_ThreadPopCall();
|
---|
2033 | #endif
|
---|
2034 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
2035 |
|
---|
2036 | RunDefWndProc:
|
---|
2037 | dprintf2(("RunDefWndProc"));
|
---|
2038 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
2039 | RestoreOS2TIB();
|
---|
2040 | //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
|
---|
2041 | // return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
2042 |
|
---|
2043 | #ifdef DEBUG
|
---|
2044 | dbg_ThreadPopCall();
|
---|
2045 | #endif
|
---|
2046 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
2047 | }
|
---|
2048 | //******************************************************************************
|
---|
2049 | //******************************************************************************
|
---|
2050 | void FrameSetFocus(HWND hwnd)
|
---|
2051 | {
|
---|
2052 | HWND hwndFocusSave = WinQueryWindowULong(hwnd, QWL_HWNDFOCUSSAVE);
|
---|
2053 | if(!WinIsWindow(hab, hwndFocusSave)) {
|
---|
2054 | hwndFocusSave = WinWindowFromID(hwnd, FID_CLIENT);
|
---|
2055 | WinSetWindowULong(hwnd, QWL_HWNDFOCUSSAVE, hwndFocusSave);
|
---|
2056 | }
|
---|
2057 | dprintf(("FrameSetFocus: hwndFocusSave %x %x", OS2ToWin32Handle(hwndFocusSave), hwndFocusSave));
|
---|
2058 | WinSetFocus(HWND_DESKTOP, hwndFocusSave);
|
---|
2059 |
|
---|
2060 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
---|
2061 | ulFrameFlags &= ~FF_NOACTIVATESWP;
|
---|
2062 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags);
|
---|
2063 | }
|
---|
2064 | //******************************************************************************
|
---|
2065 | //******************************************************************************
|
---|
2066 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
---|
2067 | HBITMAP hbmNew)
|
---|
2068 | {
|
---|
2069 | MENUITEM mi;
|
---|
2070 |
|
---|
2071 | if (!hwndMenu)
|
---|
2072 | return;
|
---|
2073 |
|
---|
2074 | WinEnableWindowUpdate(hwndMenu, FALSE);
|
---|
2075 |
|
---|
2076 | if (WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(idOld, TRUE), MPFROMP(&mi)))
|
---|
2077 | {
|
---|
2078 | WinSendMsg(hwndMenu, MM_REMOVEITEM, (MPARAM)idOld, 0);
|
---|
2079 | mi.afStyle = MIS_BITMAP | MIS_SYSCOMMAND;
|
---|
2080 | mi.afAttribute = 0;
|
---|
2081 | mi.hwndSubMenu = 0;
|
---|
2082 | mi.id = idNew;
|
---|
2083 | mi.hItem = (ULONG)hbmNew;
|
---|
2084 | WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, 0);
|
---|
2085 | }
|
---|
2086 | else
|
---|
2087 | dprintf(("WARNING: FrameReplaceMenuItem control %x not found",idOld));
|
---|
2088 |
|
---|
2089 | WinEnableWindowUpdate(hwndMenu, TRUE);
|
---|
2090 |
|
---|
2091 | WinInvalidateRect(hwndMenu, NULL, TRUE);
|
---|
2092 | }
|
---|
2093 | //******************************************************************************
|
---|
2094 | //******************************************************************************
|
---|
2095 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes)
|
---|
2096 | {
|
---|
2097 | PDRAGITEM pDragItem;
|
---|
2098 | int i, cItems;
|
---|
2099 | BOOL ret;
|
---|
2100 | char szFileName[CCHMAXPATH];
|
---|
2101 | char szContainerName[CCHMAXPATH];
|
---|
2102 | ULONG ulBytes;
|
---|
2103 | char *pszCurFile = NULL;
|
---|
2104 |
|
---|
2105 | /* Get access to the DRAGINFO data structure */
|
---|
2106 | if(!DrgAccessDraginfo(pDragInfo)) {
|
---|
2107 | return NULL;
|
---|
2108 | }
|
---|
2109 |
|
---|
2110 | cItems = DrgQueryDragitemCount(pDragInfo);
|
---|
2111 |
|
---|
2112 | //computer memory required to hold all filenames
|
---|
2113 | int bufsize = 0;
|
---|
2114 | for (i = 0; i < cItems; i++) {
|
---|
2115 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
---|
2116 |
|
---|
2117 | bufsize += DrgQueryStrNameLen(pDragItem->hstrContainerName) + DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
---|
2118 | bufsize++; //0 terminator
|
---|
2119 | bufsize++; //+ potential missing backslash
|
---|
2120 | }
|
---|
2121 | bufsize++; //extra 0 terminator
|
---|
2122 | char *pszFiles = (char *)malloc(bufsize);
|
---|
2123 | if(pszFiles == NULL) {
|
---|
2124 | dprintf(("Out of memory!!"));
|
---|
2125 | DebugInt3();
|
---|
2126 | goto failure;
|
---|
2127 | }
|
---|
2128 | memset(pszFiles, 0, bufsize);
|
---|
2129 |
|
---|
2130 | pszCurFile = pszFiles;
|
---|
2131 |
|
---|
2132 | //copy all filenames
|
---|
2133 | for (i = 0; i < cItems; i++) {
|
---|
2134 | char *pszTemp = pszCurFile;
|
---|
2135 |
|
---|
2136 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
---|
2137 |
|
---|
2138 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrContainerName);
|
---|
2139 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
---|
2140 | ulBytes, pszCurFile);
|
---|
2141 | if(pszCurFile[ulBytes-1] != '\\') {
|
---|
2142 | pszCurFile[ulBytes] = '\\';
|
---|
2143 | pszCurFile++;
|
---|
2144 | }
|
---|
2145 | pszCurFile += ulBytes;
|
---|
2146 |
|
---|
2147 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
---|
2148 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
---|
2149 | ulBytes+1, pszCurFile);
|
---|
2150 | pszCurFile += ulBytes + 1; //+ terminator
|
---|
2151 |
|
---|
2152 | dprintf(("dropped file %s", pszTemp));
|
---|
2153 | }
|
---|
2154 |
|
---|
2155 | /* Release the draginfo data structure */
|
---|
2156 | DrgFreeDraginfo(pDragInfo);
|
---|
2157 |
|
---|
2158 | *pulBytes = bufsize;
|
---|
2159 | *pcItems = cItems;
|
---|
2160 |
|
---|
2161 | return pszFiles;
|
---|
2162 |
|
---|
2163 | failure:
|
---|
2164 | /* Release the draginfo data structure */
|
---|
2165 | DrgFreeDraginfo(pDragInfo);
|
---|
2166 | if(pszFiles) {
|
---|
2167 | free(pszFiles);
|
---|
2168 | }
|
---|
2169 | return NULL;
|
---|
2170 | }
|
---|
2171 | //******************************************************************************
|
---|
2172 | //******************************************************************************
|
---|
2173 | static BOOL PMDragValidate(PDRAGINFO pDragInfo)
|
---|
2174 | {
|
---|
2175 | PDRAGITEM pDragItem;
|
---|
2176 | ULONG ulBytes;
|
---|
2177 | int i, cItems;
|
---|
2178 | BOOL ret;
|
---|
2179 | char szFileName[CCHMAXPATH];
|
---|
2180 | char szContainerName[CCHMAXPATH];
|
---|
2181 | USHORT usOp = DO_MOVE;
|
---|
2182 |
|
---|
2183 | /* Get access to the DRAGINFO data structure */
|
---|
2184 | if(!DrgAccessDraginfo(pDragInfo)) {
|
---|
2185 | return FALSE;
|
---|
2186 | }
|
---|
2187 |
|
---|
2188 | /* Can we accept this drop? */
|
---|
2189 | switch (pDragInfo->usOperation) {
|
---|
2190 | /* Return DOR_NODROPOP if current operation */
|
---|
2191 | /* is link or unknown */
|
---|
2192 | case DO_LINK:
|
---|
2193 | case DO_COPY:
|
---|
2194 | case DO_UNKNOWN:
|
---|
2195 | goto failure;
|
---|
2196 |
|
---|
2197 | /* Our default operation is Move */
|
---|
2198 | case DO_MOVE:
|
---|
2199 | case DO_DEFAULT:
|
---|
2200 | pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
|
---|
2201 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
---|
2202 | sizeof(szContainerName),
|
---|
2203 | szContainerName);
|
---|
2204 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
---|
2205 | sizeof(szFileName),
|
---|
2206 | szFileName);
|
---|
2207 | if (!ulBytes) {
|
---|
2208 | goto failure;
|
---|
2209 | }
|
---|
2210 |
|
---|
2211 | dprintf(("dropped file %s%s", szContainerName, szFileName));
|
---|
2212 | break;
|
---|
2213 | }
|
---|
2214 |
|
---|
2215 | cItems = DrgQueryDragitemCount(pDragInfo);
|
---|
2216 |
|
---|
2217 | /* Now, we need to look at each item in turn */
|
---|
2218 | for (i = 0; i < cItems; i++) {
|
---|
2219 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
---|
2220 |
|
---|
2221 | /* Make sure we can move for a Move request */
|
---|
2222 | if (!((pDragItem->fsSupportedOps & DO_MOVEABLE) &&
|
---|
2223 | (usOp == (USHORT)DO_MOVE)))
|
---|
2224 | {
|
---|
2225 | dprintf(("item %d not accepted", i));
|
---|
2226 | goto failure;
|
---|
2227 | }
|
---|
2228 | }
|
---|
2229 | /* Release the draginfo data structure */
|
---|
2230 | DrgFreeDraginfo(pDragInfo);
|
---|
2231 | return TRUE;
|
---|
2232 |
|
---|
2233 | failure:
|
---|
2234 | DrgFreeDraginfo(pDragInfo);
|
---|
2235 | return FALSE;
|
---|
2236 | }
|
---|
2237 | //******************************************************************************
|
---|
2238 | //******************************************************************************
|
---|
2239 | #ifdef DEBUG
|
---|
2240 | static char *DbgGetStringSWPFlags(ULONG flags)
|
---|
2241 | {
|
---|
2242 | static char szSWPFlags[512];
|
---|
2243 |
|
---|
2244 | szSWPFlags[0] = 0;
|
---|
2245 |
|
---|
2246 | if(flags & SWP_SIZE) {
|
---|
2247 | strcat(szSWPFlags, "SWP_SIZE ");
|
---|
2248 | }
|
---|
2249 | if(flags & SWP_MOVE) {
|
---|
2250 | strcat(szSWPFlags, "SWP_MOVE ");
|
---|
2251 | }
|
---|
2252 | if(flags & SWP_ZORDER) {
|
---|
2253 | strcat(szSWPFlags, "SWP_ZORDER ");
|
---|
2254 | }
|
---|
2255 | if(flags & SWP_SHOW) {
|
---|
2256 | strcat(szSWPFlags, "SWP_SHOW ");
|
---|
2257 | }
|
---|
2258 | if(flags & SWP_HIDE) {
|
---|
2259 | strcat(szSWPFlags, "SWP_HIDE ");
|
---|
2260 | }
|
---|
2261 | if(flags & SWP_NOREDRAW) {
|
---|
2262 | strcat(szSWPFlags, "SWP_NOREDRAW ");
|
---|
2263 | }
|
---|
2264 | if(flags & SWP_NOADJUST) {
|
---|
2265 | strcat(szSWPFlags, "SWP_NOADJUST ");
|
---|
2266 | }
|
---|
2267 | if(flags & SWP_ACTIVATE) {
|
---|
2268 | strcat(szSWPFlags, "SWP_ACTIVATE ");
|
---|
2269 | }
|
---|
2270 | if(flags & SWP_DEACTIVATE) {
|
---|
2271 | strcat(szSWPFlags, "SWP_DEACTIVATE ");
|
---|
2272 | }
|
---|
2273 | if(flags & SWP_EXTSTATECHANGE) {
|
---|
2274 | strcat(szSWPFlags, "SWP_EXTSTATECHANGE ");
|
---|
2275 | }
|
---|
2276 | if(flags & SWP_MINIMIZE) {
|
---|
2277 | strcat(szSWPFlags, "SWP_MINIMIZE ");
|
---|
2278 | }
|
---|
2279 | if(flags & SWP_MAXIMIZE) {
|
---|
2280 | strcat(szSWPFlags, "SWP_MAXIMIZE ");
|
---|
2281 | }
|
---|
2282 | if(flags & SWP_RESTORE) {
|
---|
2283 | strcat(szSWPFlags, "SWP_RESTORE ");
|
---|
2284 | }
|
---|
2285 | if(flags & SWP_FOCUSACTIVATE) {
|
---|
2286 | strcat(szSWPFlags, "SWP_FOCUSACTIVATE ");
|
---|
2287 | }
|
---|
2288 | if(flags & SWP_FOCUSDEACTIVATE) {
|
---|
2289 | strcat(szSWPFlags, "SWP_FOCUSDEACTIVATE ");
|
---|
2290 | }
|
---|
2291 | if(flags & SWP_NOAUTOCLOSE) {
|
---|
2292 | strcat(szSWPFlags, "SWP_NOAUTOCLOSE ");
|
---|
2293 | }
|
---|
2294 | return szSWPFlags;
|
---|
2295 | }
|
---|
2296 | static char *DbgPrintQFCFlags(ULONG flags)
|
---|
2297 | {
|
---|
2298 | static char szQFCFlags[64];
|
---|
2299 |
|
---|
2300 | szQFCFlags[0] = 0;
|
---|
2301 |
|
---|
2302 | if(flags & QFC_NEXTINCHAIN) {
|
---|
2303 | strcat(szQFCFlags, "QFC_NEXTINCHAIN");
|
---|
2304 | }
|
---|
2305 | else
|
---|
2306 | if(flags & QFC_ACTIVE) {
|
---|
2307 | strcat(szQFCFlags, "QFC_ACTIVE");
|
---|
2308 | }
|
---|
2309 | else
|
---|
2310 | if(flags & QFC_FRAME) {
|
---|
2311 | strcat(szQFCFlags, "QFC_FRAME");
|
---|
2312 | }
|
---|
2313 | else
|
---|
2314 | if(flags & QFC_SELECTACTIVE) {
|
---|
2315 | strcat(szQFCFlags, "QFC_SELECTACTIVE");
|
---|
2316 | }
|
---|
2317 | else
|
---|
2318 | if(flags & QFC_PARTOFCHAIN) {
|
---|
2319 | strcat(szQFCFlags, "QFC_PARTOFCHAIN");
|
---|
2320 | }
|
---|
2321 |
|
---|
2322 | return szQFCFlags;
|
---|
2323 | }
|
---|
2324 | #endif
|
---|
2325 | //******************************************************************************
|
---|
2326 | //******************************************************************************
|
---|