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