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