1 | /* $Id: pmwindow.cpp,v 1.162 2001-10-29 14:20:11 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 <stdlib.h>
|
---|
24 | #include <string.h>
|
---|
25 | #include <win32type.h>
|
---|
26 | #include <win32api.h>
|
---|
27 | #include <winconst.h>
|
---|
28 | #include <winuser32.h>
|
---|
29 | #include <wprocess.h>
|
---|
30 | #include <misc.h>
|
---|
31 | #include <win32wbase.h>
|
---|
32 | #include <win32dlg.h>
|
---|
33 | #include "win32wdesktop.h"
|
---|
34 | #include "pmwindow.h"
|
---|
35 | #include "oslibwin.h"
|
---|
36 | #include "oslibutil.h"
|
---|
37 | #include "oslibgdi.h"
|
---|
38 | #include "oslibmsg.h"
|
---|
39 | #define INCLUDED_BY_DC
|
---|
40 | #include "dc.h"
|
---|
41 | #include <thread.h>
|
---|
42 | #include <wprocess.h>
|
---|
43 | #include "caret.h"
|
---|
44 | #include "timer.h"
|
---|
45 | #include <codepage.h>
|
---|
46 | #include "syscolor.h"
|
---|
47 | #include "options.h"
|
---|
48 | #include "menu.h"
|
---|
49 | #include <pmkbdhk.h>
|
---|
50 | #include <pmscan.h>
|
---|
51 | #include <winscan.h>
|
---|
52 | #include <win\dbt.h>
|
---|
53 |
|
---|
54 | #define DBG_LOCALLOG DBG_pmwindow
|
---|
55 | #include "dbglocal.h"
|
---|
56 |
|
---|
57 | //define this to use the new code for WM_CALCVALIDRECT handling
|
---|
58 | //#define USE_CALCVALIDRECT
|
---|
59 |
|
---|
60 | HMQ hmq = 0; /* Message queue handle */
|
---|
61 | HAB hab = 0;
|
---|
62 | RECTL desktopRectl = {0};
|
---|
63 | ULONG ScreenWidth = 0;
|
---|
64 | ULONG ScreenHeight = 0;
|
---|
65 | ULONG ScreenBitsPerPel = 0;
|
---|
66 | BOOL fOS2Look = FALSE;
|
---|
67 | HBITMAP hbmFrameMenu[3] = {0};
|
---|
68 |
|
---|
69 | static PFNWP pfnFrameWndProc = NULL;
|
---|
70 | static HWND hwndFocusChange = 0;
|
---|
71 | static HWND hwndCD = 0;
|
---|
72 |
|
---|
73 | // Note:
|
---|
74 | // For a "lonekey"-press of AltGr, we only receive WM_KEYUP
|
---|
75 | // messages. If the key is pressed longer and starts to repeat,
|
---|
76 | // WM_KEYDOWN messages come in properly.
|
---|
77 | static BOOL fKeyAltGrDown = FALSE;
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
82 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
83 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
84 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
---|
85 | HBITMAP hbmNew);
|
---|
86 | void FrameSetFocus(HWND hwnd);
|
---|
87 |
|
---|
88 | VOID APIENTRY DspInitSystemDriverName(PSZ pszDriverName, ULONG lenDriverName);
|
---|
89 |
|
---|
90 | //******************************************************************************
|
---|
91 | //Initialize PM; create hab, message queue and register special Win32 window classes
|
---|
92 | //******************************************************************************
|
---|
93 | BOOL InitPM()
|
---|
94 | {
|
---|
95 | hab = WinInitialize(0);
|
---|
96 | dprintf(("Winitialize returned %x", hab));
|
---|
97 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
98 |
|
---|
99 | if(!hab || !hmq)
|
---|
100 | {
|
---|
101 | UINT error;
|
---|
102 | //CB: only fail on real error
|
---|
103 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
---|
104 | if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
|
---|
105 | {
|
---|
106 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
---|
107 | dprintf((" Error = %x",error));
|
---|
108 | return(FALSE);
|
---|
109 | }
|
---|
110 | else
|
---|
111 | {
|
---|
112 | if(!hab) {
|
---|
113 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
---|
114 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
---|
115 | }
|
---|
116 | if(!hmq) {
|
---|
117 | PTIB ptib;
|
---|
118 | PPIB ppib;
|
---|
119 |
|
---|
120 | DosGetInfoBlocks(&ptib, &ppib);
|
---|
121 |
|
---|
122 | hmq = WinQueueFromID(hab, ppib->pib_ulpid, ptib->tib_ptib2->tib2_ultid);
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|
126 | SetThreadHAB(hab);
|
---|
127 | dprintf(("InitPM: hmq = %x", hmq));
|
---|
128 | SetThreadMessageQueue(hmq);
|
---|
129 |
|
---|
130 | BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
|
---|
131 | dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
|
---|
132 |
|
---|
133 | //CD polling window class
|
---|
134 | if(!WinRegisterClass( /* Register window class */
|
---|
135 | hab, /* Anchor block handle */
|
---|
136 | (PSZ)WIN32_CDCLASS, /* Window class name */
|
---|
137 | (PFNWP)Win32CDWindowProc, /* Address of window procedure */
|
---|
138 | 0,
|
---|
139 | 0))
|
---|
140 | {
|
---|
141 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
---|
142 | return(FALSE);
|
---|
143 | }
|
---|
144 |
|
---|
145 | //Standard Odin window class
|
---|
146 | if(!WinRegisterClass( /* Register window class */
|
---|
147 | hab, /* Anchor block handle */
|
---|
148 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
---|
149 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
---|
150 | 0,
|
---|
151 | NROF_WIN32WNDBYTES))
|
---|
152 | {
|
---|
153 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
---|
154 | return(FALSE);
|
---|
155 | }
|
---|
156 |
|
---|
157 | CLASSINFO FrameClassInfo;
|
---|
158 | if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
|
---|
159 | dprintf (("WinQueryClassInfo WC_FRAME failed"));
|
---|
160 | return (FALSE);
|
---|
161 | }
|
---|
162 | pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
|
---|
163 |
|
---|
164 | dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
|
---|
165 |
|
---|
166 | if(!WinRegisterClass( /* Register window class */
|
---|
167 | hab, /* Anchor block handle */
|
---|
168 | (PSZ)WIN32_STDFRAMECLASS, /* Window class name */
|
---|
169 | (PFNWP)Win32FrameWindowProc, /* Address of window procedure */
|
---|
170 | CS_FRAME,
|
---|
171 | FrameClassInfo.cbWindowData))
|
---|
172 | {
|
---|
173 | dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
|
---|
174 | return(FALSE);
|
---|
175 | }
|
---|
176 |
|
---|
177 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
---|
178 | ScreenWidth = desktopRectl.xRight;
|
---|
179 | ScreenHeight = desktopRectl.yTop;
|
---|
180 |
|
---|
181 | HDC hdc; /* Device-context handle */
|
---|
182 | /* context data structure */
|
---|
183 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
---|
184 | NULL, NULL, NULL};
|
---|
185 |
|
---|
186 | /* create memory device context */
|
---|
187 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
---|
188 |
|
---|
189 | fOS2Look = PROFILE_GetOdinIniBool(ODINSYSTEM_SECTION, "OS2Look", FALSE);
|
---|
190 | if(fOS2Look)
|
---|
191 | {
|
---|
192 | CHAR szDisplay[30];
|
---|
193 | HMODULE hModDisplay;
|
---|
194 |
|
---|
195 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
---|
196 |
|
---|
197 | DspInitSystemDriverName(szDisplay, sizeof(szDisplay));
|
---|
198 | DosQueryModuleHandle(szDisplay, &hModDisplay);
|
---|
199 |
|
---|
200 | hbmFrameMenu[0] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTON, 0, 0);
|
---|
201 | hbmFrameMenu[1] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTON, 0, 0);
|
---|
202 | hbmFrameMenu[2] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTON, 0, 0);
|
---|
203 | }
|
---|
204 |
|
---|
205 | DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
|
---|
206 | DevCloseDC(hdc);
|
---|
207 |
|
---|
208 | dprintf(("InitPM: Desktop (%d,%d) bpp %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel));
|
---|
209 | return TRUE;
|
---|
210 | } /* End of main */
|
---|
211 | //******************************************************************************
|
---|
212 | //menu.cpp
|
---|
213 | BOOL MENU_Init();
|
---|
214 | //******************************************************************************
|
---|
215 | void WIN32API SetWindowAppearance(int fLooks)
|
---|
216 | {
|
---|
217 | if(fLooks == OS2_APPEARANCE || fLooks == OS2_APPEARANCE_SYSMENU)
|
---|
218 | {
|
---|
219 | CHAR szDisplay[30];
|
---|
220 | HMODULE hModDisplay;
|
---|
221 |
|
---|
222 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
---|
223 |
|
---|
224 | if(hbmFrameMenu[0] == 0)
|
---|
225 | {
|
---|
226 | CHAR szDisplay[30];
|
---|
227 | HMODULE hModDisplay;
|
---|
228 | HDC hdc; /* Device-context handle */
|
---|
229 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
---|
230 | NULL, NULL, NULL};
|
---|
231 |
|
---|
232 | /* create memory device context */
|
---|
233 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
---|
234 |
|
---|
235 | DspInitSystemDriverName(szDisplay, sizeof(szDisplay));
|
---|
236 | DosQueryModuleHandle(szDisplay, &hModDisplay);
|
---|
237 |
|
---|
238 | hbmFrameMenu[0] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTON, 0, 0);
|
---|
239 | hbmFrameMenu[1] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTON, 0, 0);
|
---|
240 | hbmFrameMenu[2] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTON, 0, 0);
|
---|
241 | DevCloseDC(hdc);
|
---|
242 | }
|
---|
243 | }
|
---|
244 | fOS2Look = fLooks;
|
---|
245 | MENU_Init();
|
---|
246 | }
|
---|
247 | //******************************************************************************
|
---|
248 | //CD notification window class
|
---|
249 | //******************************************************************************
|
---|
250 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
251 | {
|
---|
252 | #pragma pack(1)
|
---|
253 | typedef struct
|
---|
254 | {
|
---|
255 | BYTE ucCommandInfo;
|
---|
256 | WORD usDriveUnit;
|
---|
257 | } ParameterBlock;
|
---|
258 | #pragma pack()
|
---|
259 |
|
---|
260 | MRESULT rc = 0;
|
---|
261 | static ULONG drives[26] = {0};
|
---|
262 | static int drivestatus[26] = {0};
|
---|
263 |
|
---|
264 | switch( msg )
|
---|
265 | {
|
---|
266 | //OS/2 msgs
|
---|
267 | case WM_CREATE:
|
---|
268 | {
|
---|
269 | char drive[2];
|
---|
270 |
|
---|
271 | //skip floppy drives
|
---|
272 | drive[0] = 'C';
|
---|
273 | drive[1] = 0;
|
---|
274 |
|
---|
275 | for(int i=2;i<26;i++) {
|
---|
276 | drives[i] = GetDriveTypeA(drive);
|
---|
277 | if(drives[i] == DRIVE_CDROM_W)
|
---|
278 | {
|
---|
279 | DWORD parsize = sizeof(ParameterBlock);
|
---|
280 | DWORD datasize = 2;
|
---|
281 | WORD status = 0;
|
---|
282 | DWORD rc;
|
---|
283 | ParameterBlock parm;
|
---|
284 |
|
---|
285 | parm.ucCommandInfo = 0;
|
---|
286 | parm.usDriveUnit = i;
|
---|
287 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
---|
288 | &status, sizeof(status), &datasize);
|
---|
289 | if(rc != NO_ERROR) {
|
---|
290 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
---|
291 | drives[i] = 0;
|
---|
292 | continue;
|
---|
293 | }
|
---|
294 | //if no disk present, return FALSE
|
---|
295 | if(status & 4) {
|
---|
296 | drivestatus[i] = status & 4;
|
---|
297 | }
|
---|
298 | }
|
---|
299 | drive[0]++;
|
---|
300 | }
|
---|
301 | WinStartTimer(hab, hwnd, 17, 32*3);
|
---|
302 | //// WinStartTimer(hab, hwnd, 17, 5000);
|
---|
303 | rc = (MRESULT)FALSE;
|
---|
304 | break;
|
---|
305 | }
|
---|
306 | case WM_TIMER:
|
---|
307 | {
|
---|
308 | for(int i=0;i<26;i++)
|
---|
309 | {
|
---|
310 | //for now only cdrom/dvd drives
|
---|
311 | if(drives[i] == DRIVE_CDROM_W)
|
---|
312 | {
|
---|
313 | DWORD parsize = sizeof(ParameterBlock);
|
---|
314 | DWORD datasize = 2;
|
---|
315 | WORD status = 0;
|
---|
316 | DWORD rc;
|
---|
317 | ParameterBlock parm;
|
---|
318 |
|
---|
319 | parm.ucCommandInfo = 0;
|
---|
320 | parm.usDriveUnit = i;
|
---|
321 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
---|
322 | &status, sizeof(status), &datasize);
|
---|
323 | if(rc != NO_ERROR) {
|
---|
324 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
---|
325 | return FALSE;
|
---|
326 | }
|
---|
327 | //Send WM_DEVICECHANGE message when CD status changes
|
---|
328 | if((status & 4) != drivestatus[i])
|
---|
329 | {
|
---|
330 | PID pidThis, pidTemp;
|
---|
331 | HENUM henum;
|
---|
332 | HWND hwndEnum;
|
---|
333 | DEV_BROADCAST_VOLUME volchange;
|
---|
334 |
|
---|
335 | dprintf(("Disk status 0x%x", status));
|
---|
336 |
|
---|
337 | volchange.dbcv_size = sizeof(volchange);
|
---|
338 | volchange.dbcv_devicetype = DBT_DEVTYP_VOLUME;
|
---|
339 | volchange.dbcv_reserved = 0;
|
---|
340 | volchange.dbcv_unitmask = (1 << i);
|
---|
341 | volchange.dbcv_flags = DBTF_MEDIA;
|
---|
342 |
|
---|
343 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
---|
344 |
|
---|
345 | //Iterate over all child windows of the desktop
|
---|
346 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
---|
347 |
|
---|
348 | SetWin32TIB();
|
---|
349 | while(hwndEnum = WinGetNextWindow(henum))
|
---|
350 | {
|
---|
351 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
---|
352 | if(pidTemp == pidThis)
|
---|
353 | {
|
---|
354 | HWND hwndWin32 = OS2ToWin32Handle(hwndEnum);
|
---|
355 | if(hwndWin32) {
|
---|
356 | SendMessageA(hwndWin32,
|
---|
357 | WM_DEVICECHANGE_W,
|
---|
358 | (status & 4) ? DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE,
|
---|
359 | (LPARAM)&volchange);
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 | RestoreOS2TIB();
|
---|
364 | WinEndEnumWindows(henum);
|
---|
365 |
|
---|
366 | drivestatus[i] = (status & 4);
|
---|
367 | }
|
---|
368 | }
|
---|
369 | }
|
---|
370 | break;
|
---|
371 | }
|
---|
372 |
|
---|
373 | case WM_DESTROY:
|
---|
374 | WinStopTimer(hab, hwnd, 17);
|
---|
375 | break;
|
---|
376 |
|
---|
377 | default:
|
---|
378 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
379 | }
|
---|
380 | return (MRESULT)rc;
|
---|
381 | }
|
---|
382 | //******************************************************************************
|
---|
383 | //Win32 window message handler
|
---|
384 | //******************************************************************************
|
---|
385 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
386 | {
|
---|
387 | Win32BaseWindow *win32wnd;
|
---|
388 | TEB *teb;
|
---|
389 | MSG winMsg, *pWinMsg;
|
---|
390 | MRESULT rc = 0;
|
---|
391 | POSTMSG_PACKET *postmsg;
|
---|
392 | OSLIBPOINT point, ClientPoint;
|
---|
393 |
|
---|
394 | //Restore our FS selector
|
---|
395 | SetWin32TIB();
|
---|
396 |
|
---|
397 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
---|
398 | teb = GetThreadTEB();
|
---|
399 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
400 |
|
---|
401 | //// dprintf(("window %x msg %x", (win32wnd) ? win32wnd->getWindowHandle() : 0, msg));
|
---|
402 |
|
---|
403 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
---|
404 | dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
---|
405 | goto RunDefWndProc;
|
---|
406 | }
|
---|
407 | //// if(teb->o.odin.fIgnoreMsgs) {
|
---|
408 | //// goto RunDefWndProc;
|
---|
409 | //// }
|
---|
410 |
|
---|
411 | if((teb->o.odin.msgstate & 1) == 0)
|
---|
412 | {//message that was sent directly to our window proc handler; translate it here
|
---|
413 | QMSG qmsg;
|
---|
414 |
|
---|
415 | qmsg.msg = msg;
|
---|
416 | qmsg.hwnd = hwnd;
|
---|
417 | qmsg.mp1 = mp1;
|
---|
418 | qmsg.mp2 = mp2;
|
---|
419 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
---|
420 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
---|
421 | qmsg.reserved = 0;
|
---|
422 |
|
---|
423 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
---|
424 | {//message was not translated
|
---|
425 | memset(&winMsg, 0, sizeof(MSG));
|
---|
426 | }
|
---|
427 | pWinMsg = &winMsg;
|
---|
428 | }
|
---|
429 | else {
|
---|
430 | pWinMsg = &teb->o.odin.msg;
|
---|
431 | teb->o.odin.msgstate++;
|
---|
432 | }
|
---|
433 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
---|
434 |
|
---|
435 | if(msg >= WIN32APP_POSTMSG) {
|
---|
436 | //probably win32 app user message
|
---|
437 | dprintf2(("Posted message %x->%x", msg, msg-WIN32APP_POSTMSG));
|
---|
438 | if((ULONG)mp1 == WIN32MSG_MAGICA) {
|
---|
439 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
---|
440 | }
|
---|
441 | else
|
---|
442 | if((ULONG)mp1 == WIN32MSG_MAGICW) {
|
---|
443 | rc = (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
|
---|
444 | }
|
---|
445 | else {//broadcasted message
|
---|
446 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
---|
447 | }
|
---|
448 | RELEASE_WNDOBJ(win32wnd);
|
---|
449 | RestoreOS2TIB();
|
---|
450 | return rc;
|
---|
451 | }
|
---|
452 |
|
---|
453 | switch( msg )
|
---|
454 | {
|
---|
455 | //OS/2 msgs
|
---|
456 | case WM_CREATE:
|
---|
457 | {
|
---|
458 | if(teb->o.odin.newWindow == 0)
|
---|
459 | goto createfail;
|
---|
460 |
|
---|
461 | //Processing is done in after WinCreateWindow returns
|
---|
462 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
---|
463 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
---|
464 | win32wnd->addRef();
|
---|
465 | teb->o.odin.newWindow = 0;
|
---|
466 | if(win32wnd->MsgCreate(hwnd) == FALSE)
|
---|
467 | {
|
---|
468 | rc = (MRESULT)TRUE; //discontinue window creation
|
---|
469 | break;
|
---|
470 | }
|
---|
471 |
|
---|
472 | //Create CD notification window
|
---|
473 | if(hwndCD == 0) {
|
---|
474 | hwndCD = WinCreateWindow(HWND_DESKTOP, WIN32_CDCLASS,
|
---|
475 | NULL, 0, 0, 0, 0, 0,
|
---|
476 | HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
|
---|
477 | }
|
---|
478 |
|
---|
479 | createfail:
|
---|
480 | rc = (MRESULT)FALSE;
|
---|
481 | break;
|
---|
482 | }
|
---|
483 |
|
---|
484 | case WM_QUIT:
|
---|
485 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
---|
486 | win32wnd->MsgQuit();
|
---|
487 | break;
|
---|
488 |
|
---|
489 | case WM_CLOSE:
|
---|
490 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
---|
491 | win32wnd->MsgClose();
|
---|
492 | break;
|
---|
493 |
|
---|
494 | case WM_DESTROY:
|
---|
495 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
---|
496 | win32wnd->MsgDestroy();
|
---|
497 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
---|
498 | goto RunDefWndProc;
|
---|
499 |
|
---|
500 | case WM_ENABLE:
|
---|
501 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
---|
502 | break;
|
---|
503 |
|
---|
504 | case WM_SHOW:
|
---|
505 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
---|
506 | win32wnd->MsgShow((ULONG)mp1);
|
---|
507 | break;
|
---|
508 |
|
---|
509 | case WM_ACTIVATE:
|
---|
510 | {
|
---|
511 | ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
|
---|
512 |
|
---|
513 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
---|
514 | WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
|
---|
515 | if(win32wnd->IsWindowCreated())
|
---|
516 | {
|
---|
517 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
---|
518 | }
|
---|
519 | break;
|
---|
520 | }
|
---|
521 |
|
---|
522 | case WM_SIZE:
|
---|
523 | {
|
---|
524 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
|
---|
525 | win32wnd->SetVisibleRegionChanged(TRUE);
|
---|
526 | goto RunDefWndProc;
|
---|
527 | }
|
---|
528 |
|
---|
529 |
|
---|
530 | case WM_VRNENABLED:
|
---|
531 | dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
532 | //Always call handler; even if mp1 is 0. If we don't do this, the
|
---|
533 | //DivX 4 player will never be allowed to draw after putting another window
|
---|
534 | //on top of it.
|
---|
535 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
---|
536 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
---|
537 | {
|
---|
538 | HWND hwndrelated;
|
---|
539 | Win32BaseWindow *topwindow;
|
---|
540 |
|
---|
541 | win32wnd->setComingToTop(TRUE);
|
---|
542 |
|
---|
543 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
---|
544 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
---|
545 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
---|
546 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
---|
547 | //put window at the top of z order
|
---|
548 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
---|
549 | }
|
---|
550 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
---|
551 |
|
---|
552 | win32wnd->setComingToTop(FALSE);
|
---|
553 | break;
|
---|
554 | }
|
---|
555 | goto RunDefWndProc;
|
---|
556 |
|
---|
557 | case WM_VRNDISABLED:
|
---|
558 | dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
559 | //visible region is about to change or WinLockWindowUpdate called
|
---|
560 | //suspend window drawing
|
---|
561 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
---|
562 | goto RunDefWndProc;
|
---|
563 |
|
---|
564 | case WIN32APP_SETFOCUSMSG:
|
---|
565 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
---|
566 | //must delay this function call
|
---|
567 | //mp1 = win32 window handle
|
---|
568 | //mp2 = top parent if activation required
|
---|
569 | dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
|
---|
570 | if(teb->o.odin.hwndFocus) {
|
---|
571 | RELEASE_WNDOBJ(win32wnd);
|
---|
572 | win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
|
---|
573 | if(win32wnd) {
|
---|
574 | if(mp2) {
|
---|
575 | SetActiveWindow((HWND)mp2);
|
---|
576 | }
|
---|
577 | if(!IsWindow(win32wnd->getWindowHandle())) break; //abort if window destroyed
|
---|
578 | WinFocusChange(HWND_DESKTOP, win32wnd->getOS2WindowHandle(), FC_NOSETACTIVE);
|
---|
579 | }
|
---|
580 | else DebugInt3();
|
---|
581 | }
|
---|
582 | break;
|
---|
583 |
|
---|
584 | case WM_SETFOCUS:
|
---|
585 | {
|
---|
586 | HWND hwndFocus = (HWND)mp1;
|
---|
587 |
|
---|
588 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2));
|
---|
589 |
|
---|
590 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
---|
591 | //must delay this function call
|
---|
592 |
|
---|
593 | teb->o.odin.fWM_SETFOCUS = TRUE;
|
---|
594 | teb->o.odin.hwndFocus = 0;
|
---|
595 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
|
---|
596 | {
|
---|
597 | //another (non-win32) application's window
|
---|
598 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
---|
599 | hwndFocus = NULL;
|
---|
600 | }
|
---|
601 | if((ULONG)mp2 == TRUE) {
|
---|
602 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
---|
603 | recreateCaret (hwndFocusWin32);
|
---|
604 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
---|
605 | }
|
---|
606 | else win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
---|
607 | teb->o.odin.fWM_SETFOCUS = FALSE;
|
---|
608 |
|
---|
609 | break;
|
---|
610 | }
|
---|
611 |
|
---|
612 | //**************************************************************************
|
---|
613 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
614 | //**************************************************************************
|
---|
615 |
|
---|
616 | case WM_BUTTON1DOWN:
|
---|
617 | case WM_BUTTON1UP:
|
---|
618 | case WM_BUTTON1DBLCLK:
|
---|
619 | case WM_BUTTON2DOWN:
|
---|
620 | case WM_BUTTON2UP:
|
---|
621 | case WM_BUTTON2DBLCLK:
|
---|
622 | case WM_BUTTON3DOWN:
|
---|
623 | case WM_BUTTON3UP:
|
---|
624 | case WM_BUTTON3DBLCLK:
|
---|
625 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
626 | RELEASE_WNDOBJ(win32wnd);
|
---|
627 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
628 | }
|
---|
629 | if(win32wnd)
|
---|
630 | win32wnd->MsgButton(pWinMsg);
|
---|
631 |
|
---|
632 | rc = (MRESULT)TRUE;
|
---|
633 | break;
|
---|
634 |
|
---|
635 | case WM_BUTTON2MOTIONSTART:
|
---|
636 | case WM_BUTTON2MOTIONEND:
|
---|
637 | case WM_BUTTON2CLICK:
|
---|
638 | case WM_BUTTON1MOTIONSTART:
|
---|
639 | case WM_BUTTON1MOTIONEND:
|
---|
640 | case WM_BUTTON1CLICK:
|
---|
641 | case WM_BUTTON3MOTIONSTART:
|
---|
642 | case WM_BUTTON3MOTIONEND:
|
---|
643 | case WM_BUTTON3CLICK:
|
---|
644 | rc = (MRESULT)TRUE;
|
---|
645 | break;
|
---|
646 |
|
---|
647 | case WM_MOUSEMOVE:
|
---|
648 | {
|
---|
649 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
650 | RELEASE_WNDOBJ(win32wnd);
|
---|
651 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
652 | }
|
---|
653 | if(win32wnd)
|
---|
654 | win32wnd->MsgMouseMove(pWinMsg);
|
---|
655 | break;
|
---|
656 | }
|
---|
657 |
|
---|
658 | case WM_CONTROL:
|
---|
659 | goto RunDefWndProc;
|
---|
660 |
|
---|
661 | case WM_COMMAND:
|
---|
662 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
---|
663 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
664 | break;
|
---|
665 |
|
---|
666 | case WM_SYSCOMMAND:
|
---|
667 | dprintf(("OS2: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
668 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
669 | break;
|
---|
670 |
|
---|
671 | case WM_RENDERFMT:
|
---|
672 | case WM_RENDERALLFMTS:
|
---|
673 | case WM_DESTROYCLIPBOARD:
|
---|
674 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
675 | break;
|
---|
676 |
|
---|
677 | case WM_CHAR_SPECIAL:
|
---|
678 | /* NO BREAK! FALLTHRU CASE! */
|
---|
679 |
|
---|
680 | case WM_CHAR:
|
---|
681 | dprintf(("OS2: WM_CHAR %x %x %x, %x %x", win32wnd->getWindowHandle(), mp1, mp2, pWinMsg->wParam, pWinMsg->lParam));
|
---|
682 | win32wnd->MsgChar(pWinMsg);
|
---|
683 | break;
|
---|
684 |
|
---|
685 | case WM_TIMER:
|
---|
686 | dprintf(("OS2: WM_TIMER %x %x time %x", win32wnd->getWindowHandle(), pWinMsg->wParam, GetTickCount()));
|
---|
687 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
688 | goto RunDefWndProc;
|
---|
689 |
|
---|
690 | case WM_SETWINDOWPARAMS:
|
---|
691 | {
|
---|
692 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
---|
693 |
|
---|
694 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
---|
695 | if(wndParams->fsStatus & WPM_TEXT) {
|
---|
696 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
---|
697 | }
|
---|
698 | goto RunDefWndProc;
|
---|
699 | }
|
---|
700 |
|
---|
701 | case WM_QUERYWINDOWPARAMS:
|
---|
702 | {
|
---|
703 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
---|
704 | ULONG textlen;
|
---|
705 | PSZ wintext;
|
---|
706 |
|
---|
707 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
---|
708 | {
|
---|
709 | if(wndpars->fsStatus & WPM_TEXT)
|
---|
710 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
---|
711 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
---|
712 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
---|
713 |
|
---|
714 | wndpars->fsStatus = 0;
|
---|
715 | wndpars->cbCtlData = 0;
|
---|
716 | wndpars->cbPresParams = 0;
|
---|
717 | rc = (MRESULT)TRUE;
|
---|
718 | break;
|
---|
719 | }
|
---|
720 | goto RunDefWndProc;
|
---|
721 | }
|
---|
722 |
|
---|
723 | case WM_PAINT:
|
---|
724 | {
|
---|
725 | RECTL rectl;
|
---|
726 | BOOL rc;
|
---|
727 |
|
---|
728 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
---|
729 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
---|
730 |
|
---|
731 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
---|
732 | rectl.yBottom != rectl.yTop))
|
---|
733 | {
|
---|
734 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
735 | }
|
---|
736 | else goto RunDefWndProc;
|
---|
737 | break;
|
---|
738 | }
|
---|
739 |
|
---|
740 | case WM_ERASEBACKGROUND:
|
---|
741 | {
|
---|
742 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
---|
743 | rc = (MRESULT)FALSE;
|
---|
744 | break;
|
---|
745 | }
|
---|
746 |
|
---|
747 | case WM_CALCVALIDRECTS:
|
---|
748 | dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
749 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
---|
750 | break;
|
---|
751 |
|
---|
752 | case WM_REALIZEPALETTE:
|
---|
753 | {
|
---|
754 | dprintf(("OS2: WM_REALIZEPALETTE"));
|
---|
755 | goto RunDefWndProc;
|
---|
756 | }
|
---|
757 |
|
---|
758 | case WM_HSCROLL:
|
---|
759 | case WM_VSCROLL:
|
---|
760 | dprintf(("OS2: %s %x %x %x", (msg == WM_HSCROLL) ? "WM_HSCROLL" : "WM_VSCROLL", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
761 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
762 | break;
|
---|
763 |
|
---|
764 | case WM_DDE_INITIATE:
|
---|
765 | case WM_DDE_INITIATEACK:
|
---|
766 | case WM_DDE_REQUEST:
|
---|
767 | case WM_DDE_ACK:
|
---|
768 | case WM_DDE_DATA:
|
---|
769 | case WM_DDE_ADVISE:
|
---|
770 | case WM_DDE_UNADVISE:
|
---|
771 | case WM_DDE_POKE:
|
---|
772 | case WM_DDE_EXECUTE:
|
---|
773 | case WM_DDE_TERMINATE:
|
---|
774 | dprintf(("OS2: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
---|
775 | goto RunDefWndProc;
|
---|
776 |
|
---|
777 | case WM_INITMENU:
|
---|
778 | case WM_MENUSELECT:
|
---|
779 | case WM_MENUEND:
|
---|
780 | case WM_NEXTMENU:
|
---|
781 | case WM_SYSCOLORCHANGE:
|
---|
782 | case WM_SYSVALUECHANGED:
|
---|
783 | case WM_SETSELECTION:
|
---|
784 | case WM_PPAINT:
|
---|
785 | case WM_PSETFOCUS:
|
---|
786 | case WM_PSYSCOLORCHANGE:
|
---|
787 | case WM_PSIZE:
|
---|
788 | case WM_PACTIVATE:
|
---|
789 | case WM_PCONTROL:
|
---|
790 | case WM_HELP:
|
---|
791 | case WM_APPTERMINATENOTIFY:
|
---|
792 | case WM_PRESPARAMCHANGED:
|
---|
793 | case WM_DRAWITEM:
|
---|
794 | case WM_MEASUREITEM:
|
---|
795 | case WM_CONTROLPOINTER:
|
---|
796 | case WM_QUERYDLGCODE:
|
---|
797 | case WM_SUBSTITUTESTRING:
|
---|
798 | case WM_MATCHMNEMONIC:
|
---|
799 | case WM_SAVEAPPLICATION:
|
---|
800 | case WM_SEMANTICEVENT:
|
---|
801 | default:
|
---|
802 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
---|
803 | goto RunDefWndProc;
|
---|
804 | }
|
---|
805 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
806 | RestoreOS2TIB();
|
---|
807 | return (MRESULT)rc;
|
---|
808 |
|
---|
809 | RunDefWndProc:
|
---|
810 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
---|
811 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
812 | RestoreOS2TIB();
|
---|
813 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
814 | } /* End of Win32WindowProc */
|
---|
815 | //******************************************************************************
|
---|
816 | //******************************************************************************
|
---|
817 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
818 | {
|
---|
819 | POSTMSG_PACKET *postmsg;
|
---|
820 | OSLIBPOINT point, ClientPoint;
|
---|
821 | Win32BaseWindow *win32wnd;
|
---|
822 | TEB *teb;
|
---|
823 | MRESULT rc = 0;
|
---|
824 | MSG winMsg, *pWinMsg;
|
---|
825 |
|
---|
826 | //Restore our FS selector
|
---|
827 | SetWin32TIB();
|
---|
828 |
|
---|
829 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
---|
830 | teb = GetThreadTEB();
|
---|
831 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
---|
832 |
|
---|
833 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
---|
834 | dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
---|
835 | goto RunDefFrameWndProc;
|
---|
836 | }
|
---|
837 | //// if(teb->o.odin.fIgnoreMsgs) {
|
---|
838 | //// goto RunDefWndProc;
|
---|
839 | //// }
|
---|
840 |
|
---|
841 | if((teb->o.odin.msgstate & 1) == 0)
|
---|
842 | {//message that was sent directly to our window proc handler; translate it here
|
---|
843 | QMSG qmsg;
|
---|
844 |
|
---|
845 | qmsg.msg = msg;
|
---|
846 | qmsg.hwnd = hwnd;
|
---|
847 | qmsg.mp1 = mp1;
|
---|
848 | qmsg.mp2 = mp2;
|
---|
849 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
---|
850 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
---|
851 | qmsg.reserved = 0;
|
---|
852 |
|
---|
853 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
---|
854 | {//message was not translated
|
---|
855 | memset(&winMsg, 0, sizeof(MSG));
|
---|
856 | }
|
---|
857 | pWinMsg = &winMsg;
|
---|
858 | }
|
---|
859 | else {
|
---|
860 | pWinMsg = &teb->o.odin.msg;
|
---|
861 | teb->o.odin.msgstate++;
|
---|
862 | }
|
---|
863 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
---|
864 |
|
---|
865 | switch( msg )
|
---|
866 | {
|
---|
867 | case WM_CREATE:
|
---|
868 | {
|
---|
869 | //WM_CREATE handled during client window creation
|
---|
870 | dprintf(("PMFRAME: WM_CREATE %x", hwnd));
|
---|
871 | goto RunDefFrameWndProc;
|
---|
872 | }
|
---|
873 |
|
---|
874 | case WM_PAINT:
|
---|
875 | {
|
---|
876 | RECTL rectl;
|
---|
877 |
|
---|
878 | HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
|
---|
879 | dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
---|
880 |
|
---|
881 | if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
---|
882 | rectl.yBottom != rectl.yTop))
|
---|
883 | {
|
---|
884 | PRECT pClient = win32wnd->getClientRectPtr();
|
---|
885 | PRECT pWindow = win32wnd->getWindowRect();
|
---|
886 |
|
---|
887 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
---|
888 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
---|
889 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
---|
890 | {
|
---|
891 | RECT rectUpdate;
|
---|
892 |
|
---|
893 | mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
|
---|
894 | win32wnd->MsgNCPaint(&rectUpdate);
|
---|
895 | }
|
---|
896 | }
|
---|
897 | WinEndPaint(hps);
|
---|
898 | break;
|
---|
899 | }
|
---|
900 |
|
---|
901 | case WM_ERASEBACKGROUND:
|
---|
902 | {
|
---|
903 | dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
---|
904 | rc = (MRESULT)FALSE;
|
---|
905 | break;
|
---|
906 | }
|
---|
907 |
|
---|
908 | //**************************************************************************
|
---|
909 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
910 | //**************************************************************************
|
---|
911 |
|
---|
912 | case WM_BUTTON1DOWN:
|
---|
913 | case WM_BUTTON1UP:
|
---|
914 | case WM_BUTTON1DBLCLK:
|
---|
915 | case WM_BUTTON2DOWN:
|
---|
916 | case WM_BUTTON2UP:
|
---|
917 | case WM_BUTTON2DBLCLK:
|
---|
918 | case WM_BUTTON3DOWN:
|
---|
919 | case WM_BUTTON3UP:
|
---|
920 | case WM_BUTTON3DBLCLK:
|
---|
921 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
922 | RELEASE_WNDOBJ(win32wnd);
|
---|
923 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
924 | }
|
---|
925 | if(win32wnd)
|
---|
926 | win32wnd->MsgButton(pWinMsg);
|
---|
927 |
|
---|
928 | rc = (MRESULT)TRUE;
|
---|
929 | break;
|
---|
930 |
|
---|
931 | case WM_BUTTON2MOTIONSTART:
|
---|
932 | case WM_BUTTON2MOTIONEND:
|
---|
933 | case WM_BUTTON2CLICK:
|
---|
934 | case WM_BUTTON1MOTIONSTART:
|
---|
935 | case WM_BUTTON1MOTIONEND:
|
---|
936 | case WM_BUTTON1CLICK:
|
---|
937 | case WM_BUTTON3MOTIONSTART:
|
---|
938 | case WM_BUTTON3MOTIONEND:
|
---|
939 | case WM_BUTTON3CLICK:
|
---|
940 | rc = (MRESULT)TRUE;
|
---|
941 | break;
|
---|
942 |
|
---|
943 | case WM_MOUSEMOVE:
|
---|
944 | {
|
---|
945 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
946 | RELEASE_WNDOBJ(win32wnd);
|
---|
947 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
948 | }
|
---|
949 | if(win32wnd)
|
---|
950 | win32wnd->MsgMouseMove(pWinMsg);
|
---|
951 | break;
|
---|
952 | }
|
---|
953 |
|
---|
954 | case WM_ADJUSTWINDOWPOS:
|
---|
955 | {
|
---|
956 | PSWP pswp = (PSWP)mp1;
|
---|
957 | SWP swpOld;
|
---|
958 | WINDOWPOS wp,wpOld;
|
---|
959 | ULONG ulFlags;
|
---|
960 | ULONG ret = 0;
|
---|
961 | HWND hParent = NULLHANDLE, hwndAfter;
|
---|
962 |
|
---|
963 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
964 |
|
---|
965 | ulFlags = pswp->fl;
|
---|
966 |
|
---|
967 | if(win32wnd->IsParentChanging()) {
|
---|
968 | rc = 0;
|
---|
969 | break;
|
---|
970 | }
|
---|
971 |
|
---|
972 | if(pswp->fl & SWP_NOADJUST) {
|
---|
973 | //ignore weird messages (TODO: why are they sent?)
|
---|
974 | dprintf(("WARNING: WM_ADJUSTWINDOWPOS with SWP_NOADJUST flag!!"));
|
---|
975 | break;
|
---|
976 | }
|
---|
977 | //CB: show dialog in front of owner
|
---|
978 | if (win32wnd->IsModalDialogOwner())
|
---|
979 | {
|
---|
980 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
---|
981 | pswp->fl |= SWP_ZORDER;
|
---|
982 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
---|
983 | if (pswp->fl & SWP_ACTIVATE)
|
---|
984 | {
|
---|
985 | pswp->fl &= ~SWP_ACTIVATE;
|
---|
986 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
---|
987 | }
|
---|
988 | }
|
---|
989 |
|
---|
990 | if(!win32wnd->CanReceiveSizeMsgs())
|
---|
991 | break;
|
---|
992 |
|
---|
993 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
994 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
995 | if (win32wnd->isChild()) {
|
---|
996 | if(win32wnd->getParent()) {
|
---|
997 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
998 | }
|
---|
999 | else goto RunDefFrameWndProc;
|
---|
1000 | }
|
---|
1001 | }
|
---|
1002 | hwndAfter = pswp->hwndInsertBehind;
|
---|
1003 | if(win32wnd->getParent()) {
|
---|
1004 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
|
---|
1005 | }
|
---|
1006 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1007 |
|
---|
1008 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1009 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1010 | {
|
---|
1011 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1012 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
---|
1013 | if(wndAfter) {
|
---|
1014 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1015 | RELEASE_WNDOBJ(wndAfter);
|
---|
1016 | }
|
---|
1017 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | wpOld = wp;
|
---|
1021 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
---|
1022 |
|
---|
1023 | if(win32wnd->getOldStyle() != win32wnd->getStyle())
|
---|
1024 | {
|
---|
1025 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), win32wnd->getStyle(), win32wnd->getExStyle());
|
---|
1026 | if(fOS2Look) {
|
---|
1027 | DWORD dwOldStyle = win32wnd->getOldStyle();
|
---|
1028 | DWORD dwStyle = win32wnd->getStyle();
|
---|
1029 |
|
---|
1030 | if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
|
---|
1031 | //SC_RESTORE -> SC_MINIMIZE
|
---|
1032 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_RESTORE, SC_MINIMIZE, hbmFrameMenu[0]);
|
---|
1033 | }
|
---|
1034 | else
|
---|
1035 | if((dwOldStyle & WS_MAXIMIZE_W) && !(dwStyle & WS_MAXIMIZE_W)) {
|
---|
1036 | //SC_RESTORE -> SC_MAXIMIZE
|
---|
1037 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_RESTORE, SC_MAXIMIZE, hbmFrameMenu[1]);
|
---|
1038 | }
|
---|
1039 | else
|
---|
1040 | if(!(dwOldStyle & WS_MINIMIZE_W) && (dwStyle & WS_MINIMIZE_W)) {
|
---|
1041 | //SC_MINIMIZE -> SC_RESTORE
|
---|
1042 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_MINIMIZE, SC_RESTORE, hbmFrameMenu[2]);
|
---|
1043 | }
|
---|
1044 | else
|
---|
1045 | if(!(dwOldStyle & WS_MAXIMIZE_W) && (dwStyle & WS_MAXIMIZE_W)) {
|
---|
1046 | //SC_MAXIMIZE -> SC_RESTORE
|
---|
1047 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[2]);
|
---|
1048 | }
|
---|
1049 | }
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
---|
1053 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
---|
1054 | {
|
---|
1055 | ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
|
---|
1056 |
|
---|
1057 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
---|
1058 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1059 |
|
---|
1060 | if(win32wnd->getParent()) {
|
---|
1061 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1062 | hwnd);
|
---|
1063 | }
|
---|
1064 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1065 |
|
---|
1066 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1067 |
|
---|
1068 | //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
|
---|
1069 | if(pswp->fl & SWP_SIZE)
|
---|
1070 | flags |= SWP_SIZE;
|
---|
1071 |
|
---|
1072 | if(pswp->fl & SWP_MOVE)
|
---|
1073 | flags |= SWP_MOVE;
|
---|
1074 |
|
---|
1075 | pswp->fl = flags; //restore flags
|
---|
1076 |
|
---|
1077 | pswp->fl |= SWP_NOADJUST;
|
---|
1078 | pswp->hwndInsertBehind = hwndAfter;
|
---|
1079 | pswp->hwnd = hwnd;
|
---|
1080 |
|
---|
1081 | ret = 0xf;
|
---|
1082 | }
|
---|
1083 | adjustend:
|
---|
1084 | //The next part needs to be done for top-level windows only
|
---|
1085 | if(!((win32wnd->getStyle() & (WS_POPUP_W|WS_CHILD_W)) == WS_CHILD_W))
|
---|
1086 | {
|
---|
1087 | //Setting these flags is necessary to avoid activation/focus problems
|
---|
1088 | if(ulFlags & SWP_DEACTIVATE) {
|
---|
1089 | ret |= AWP_DEACTIVATE;
|
---|
1090 | }
|
---|
1091 | if(ulFlags & SWP_ACTIVATE)
|
---|
1092 | {
|
---|
1093 | if(ulFlags & SWP_ZORDER) {
|
---|
1094 | dprintf(("Set FF_NOACTIVATESWP"));
|
---|
1095 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
---|
1096 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags | FF_NOACTIVATESWP);
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | if(!(ulFlags & SWP_SHOW))
|
---|
1100 | {
|
---|
1101 | ret |= AWP_ACTIVATE;
|
---|
1102 | }
|
---|
1103 | else
|
---|
1104 | {
|
---|
1105 | FrameSetFocus(hwnd);
|
---|
1106 | }
|
---|
1107 | }
|
---|
1108 | }
|
---|
1109 | else {
|
---|
1110 | if(ulFlags & (SWP_ACTIVATE|SWP_FOCUSACTIVATE))
|
---|
1111 | {
|
---|
1112 | win32wnd->MsgChildActivate(TRUE);
|
---|
1113 | if(fOS2Look) {
|
---|
1114 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1115 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
---|
1116 | }
|
---|
1117 | }
|
---|
1118 | else
|
---|
1119 | if(ulFlags & (SWP_DEACTIVATE|SWP_FOCUSDEACTIVATE))
|
---|
1120 | {
|
---|
1121 | win32wnd->MsgChildActivate(FALSE);
|
---|
1122 | if(fOS2Look) {
|
---|
1123 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1124 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
---|
1125 | }
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 | dprintf(("WM_ADJUSTWINDOWPOS ret %x flags %x", ret, WinQueryWindowUShort(hwnd, QWS_FLAGS)));
|
---|
1129 | rc = (MRESULT)ret;
|
---|
1130 | break;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | case WM_WINDOWPOSCHANGED:
|
---|
1134 | {
|
---|
1135 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
---|
1136 | SWP swpOld = *(pswp + 1);
|
---|
1137 | WINDOWPOS wp;
|
---|
1138 | ULONG flAfp = (ULONG)mp2;
|
---|
1139 | HWND hParent = NULLHANDLE;
|
---|
1140 | RECTL rect;
|
---|
1141 |
|
---|
1142 | dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1143 | if(win32wnd->IsParentChanging()) {
|
---|
1144 | goto PosChangedEnd;
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | //SvL: When a window is made visible, then we don't receive a
|
---|
1148 | // WM_VRNENABLED message (for some weird reason)
|
---|
1149 | if(pswp->fl & SWP_SHOW) {
|
---|
1150 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
---|
1151 | }
|
---|
1152 | else
|
---|
1153 | if(pswp->fl & SWP_HIDE) {
|
---|
1154 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
---|
1158 | {
|
---|
1159 | if(pswp->fl & SWP_RESTORE && win32wnd->getStyle() & WS_MINIMIZE_W) {
|
---|
1160 | dprintf(("Restoring minimized window %x", win32wnd->getWindowHandle()));
|
---|
1161 | win32wnd->ShowWindow(SW_RESTORE_W);
|
---|
1162 | }
|
---|
1163 | if(pswp->fl & SWP_SHOW) {
|
---|
1164 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
---|
1165 | }
|
---|
1166 | else
|
---|
1167 | if(pswp->fl & SWP_HIDE) {
|
---|
1168 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
---|
1169 | }
|
---|
1170 | //MUST call the old frame window proc!
|
---|
1171 | goto RunDefFrameWndProc;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
---|
1175 | {
|
---|
1176 | if(win32wnd->isChild())
|
---|
1177 | {
|
---|
1178 | if(win32wnd->getParent()) {
|
---|
1179 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
1180 | }
|
---|
1181 | else goto PosChangedEnd; //parent has just been destroyed
|
---|
1182 | }
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 |
|
---|
1186 | if(win32wnd->getParent()) {
|
---|
1187 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1188 | hwnd);
|
---|
1189 | }
|
---|
1190 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
---|
1191 |
|
---|
1192 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1193 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1194 | {
|
---|
1195 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1196 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
---|
1197 | if(wndAfter) {
|
---|
1198 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1199 | RELEASE_WNDOBJ(wndAfter);
|
---|
1200 | }
|
---|
1201 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 | if(pswp->fl & SWP_SHOW) {
|
---|
1205 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
---|
1206 | }
|
---|
1207 | else
|
---|
1208 | if(pswp->fl & SWP_HIDE) {
|
---|
1209 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | if(flAfp & AWP_ACTIVATE)
|
---|
1213 | {
|
---|
1214 | FrameSetFocus(hwnd);
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | #ifndef USE_CALCVALIDRECT
|
---|
1218 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
|
---|
1219 | {
|
---|
1220 | //CB: todo: use result for WM_CALCVALIDRECTS
|
---|
1221 | //Get old client rectangle (for invalidation of frame window parts later on)
|
---|
1222 | //Use new window height to calculate the client area
|
---|
1223 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
---|
1224 |
|
---|
1225 | //Note: Also updates the new window rectangle
|
---|
1226 | win32wnd->MsgFormatFrame(&wp);
|
---|
1227 |
|
---|
1228 | if(win32wnd->isOwnDC()) {
|
---|
1229 | setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
1233 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
1234 |
|
---|
1235 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
---|
1236 | {
|
---|
1237 | //redraw the frame (to prevent unnecessary client updates)
|
---|
1238 | BOOL redrawAll = FALSE;
|
---|
1239 |
|
---|
1240 | dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
|
---|
1241 | if (win32wnd->getWindowClass())
|
---|
1242 | {
|
---|
1243 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
---|
1244 |
|
---|
1245 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
---|
1246 | redrawAll = TRUE;
|
---|
1247 | else
|
---|
1248 | if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
---|
1249 | redrawAll = TRUE;
|
---|
1250 | }
|
---|
1251 | else redrawAll = TRUE;
|
---|
1252 |
|
---|
1253 | if(win32wnd->IsMixMaxStateChanging()) {
|
---|
1254 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
---|
1255 | redrawAll = TRUE;
|
---|
1256 | }
|
---|
1257 |
|
---|
1258 | if (redrawAll)
|
---|
1259 | {
|
---|
1260 | //CB: redraw all children for now
|
---|
1261 | // -> problems with update region if we don't do it
|
---|
1262 | // todo: rewrite whole handling
|
---|
1263 | WinInvalidateRect(hwnd,NULL,TRUE);
|
---|
1264 | }
|
---|
1265 | else
|
---|
1266 | {
|
---|
1267 | HPS hps = WinGetPS(hwnd);
|
---|
1268 | RECTL frame,client,arcl[4];
|
---|
1269 |
|
---|
1270 | WinQueryWindowRect(hwnd,&frame);
|
---|
1271 |
|
---|
1272 | //top
|
---|
1273 | arcl[0].xLeft = 0;
|
---|
1274 | arcl[0].xRight = frame.xRight;
|
---|
1275 | arcl[0].yBottom = rect.yTop;
|
---|
1276 | arcl[0].yTop = frame.yTop;
|
---|
1277 | //right
|
---|
1278 | arcl[1].xLeft = rect.xRight;
|
---|
1279 | arcl[1].xRight = frame.xRight;
|
---|
1280 | arcl[1].yBottom = 0;
|
---|
1281 | arcl[1].yTop = frame.yTop;
|
---|
1282 | //left
|
---|
1283 | arcl[2].xLeft = 0;
|
---|
1284 | arcl[2].xRight = rect.xLeft;
|
---|
1285 | arcl[2].yBottom = 0;
|
---|
1286 | arcl[2].yTop = frame.yTop;
|
---|
1287 | //bottom
|
---|
1288 | arcl[3].xLeft = 0;
|
---|
1289 | arcl[3].xRight = frame.xRight;
|
---|
1290 | arcl[3].yBottom = 0;
|
---|
1291 | arcl[3].yTop = rect.yBottom;
|
---|
1292 |
|
---|
1293 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
---|
1294 |
|
---|
1295 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
---|
1296 | GpiDestroyRegion(hps,hrgn);
|
---|
1297 | WinReleasePS(hps);
|
---|
1298 | }
|
---|
1299 | }
|
---|
1300 | }
|
---|
1301 | else
|
---|
1302 | {
|
---|
1303 | #endif //USE_CALCVALIDRECT
|
---|
1304 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
1305 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
1306 | #ifndef USE_CALCVALIDRECT
|
---|
1307 | }
|
---|
1308 | #endif
|
---|
1309 |
|
---|
1310 | PosChangedEnd:
|
---|
1311 | rc = (MRESULT)FALSE;
|
---|
1312 | break;
|
---|
1313 | }
|
---|
1314 |
|
---|
1315 | case WM_CALCVALIDRECTS:
|
---|
1316 | #ifdef USE_CALCVALIDRECT
|
---|
1317 | {
|
---|
1318 | PRECTL oldRect = (PRECTL)mp1, newRect = oldRect+1;
|
---|
1319 | PSWP pswp = (PSWP)mp2;
|
---|
1320 | SWP swpOld;
|
---|
1321 | WINDOWPOS wp;
|
---|
1322 | RECTL newClientRect, oldClientRect;
|
---|
1323 | ULONG nccalcret;
|
---|
1324 | // UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
---|
1325 | UINT res = 0;
|
---|
1326 |
|
---|
1327 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
1328 |
|
---|
1329 | //Get old position info
|
---|
1330 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
1331 |
|
---|
1332 | if(win32wnd->getParent()) {
|
---|
1333 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
1334 | win32wnd->getParent()->getClientRectPtr()->left,
|
---|
1335 | win32wnd->getParent()->getClientRectPtr()->top,
|
---|
1336 | hwnd);
|
---|
1337 | }
|
---|
1338 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
---|
1339 |
|
---|
1340 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
1341 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
1342 | {
|
---|
1343 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
1344 | if(wndAfter) {
|
---|
1345 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
1346 | RELEASE_WNDOBJ(wndAfter);
|
---|
1347 | }
|
---|
1348 | else wp.hwndInsertAfter = HWND_TOP_W;
|
---|
1349 | }
|
---|
1350 |
|
---|
1351 | //Get old client rectangle
|
---|
1352 | mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
|
---|
1353 |
|
---|
1354 | //Note: Also updates the new window rectangle
|
---|
1355 | nccalcret = win32wnd->MsgFormatFrame(&wp);
|
---|
1356 |
|
---|
1357 | //Get new client rectangle
|
---|
1358 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
|
---|
1359 |
|
---|
1360 | if(nccalcret == 0) {
|
---|
1361 | res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
|
---|
1362 | }
|
---|
1363 | else {
|
---|
1364 | if(nccalcret & WVR_ALIGNTOP_W) {
|
---|
1365 | res |= CVR_ALIGNTOP;
|
---|
1366 | }
|
---|
1367 | else
|
---|
1368 | if(nccalcret & WVR_ALIGNBOTTOM_W) {
|
---|
1369 | res |= CVR_ALIGNBOTTOM;
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | if(nccalcret & WVR_ALIGNLEFT_W) {
|
---|
1373 | res |= CVR_ALIGNLEFT;
|
---|
1374 | }
|
---|
1375 | else
|
---|
1376 | if(nccalcret & WVR_ALIGNRIGHT_W) {
|
---|
1377 | res |= CVR_ALIGNRIGHT;
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
|
---|
1381 | res |= CVR_REDRAW;
|
---|
1382 | }
|
---|
1383 | else
|
---|
1384 | if(nccalcret & WVR_VALIDRECTS_W) {
|
---|
1385 | //TODO:
|
---|
1386 | //res = 0;
|
---|
1387 | }
|
---|
1388 | }
|
---|
1389 | if(win32wnd->IsMixMaxStateChanging()) {
|
---|
1390 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
---|
1391 | res |= CVR_REDRAW;
|
---|
1392 | }
|
---|
1393 | if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
|
---|
1394 | oldRect->xRight -= oldClientRect.xLeft;
|
---|
1395 | oldRect->yBottom += oldClientRect.yBottom;
|
---|
1396 | newRect->xRight -= newClientRect.xLeft;
|
---|
1397 | newRect->yBottom += newClientRect.yBottom;
|
---|
1398 | }
|
---|
1399 | rc = res;
|
---|
1400 | break;
|
---|
1401 | }
|
---|
1402 | #else
|
---|
1403 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
---|
1404 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
---|
1405 | break;
|
---|
1406 | #endif
|
---|
1407 |
|
---|
1408 | case WM_CALCFRAMERECT:
|
---|
1409 | dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
---|
1410 | rc = (MRESULT)TRUE;
|
---|
1411 | break;
|
---|
1412 |
|
---|
1413 | case WM_QUERYCTLTYPE:
|
---|
1414 | // This is a frame window
|
---|
1415 | dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
---|
1416 | rc = (MRESULT)CCT_FRAME;
|
---|
1417 | break;
|
---|
1418 |
|
---|
1419 | #ifdef DEBUG
|
---|
1420 | case WM_QUERYFOCUSCHAIN:
|
---|
1421 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0));
|
---|
1422 |
|
---|
1423 | RestoreOS2TIB();
|
---|
1424 | rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
1425 | SetWin32TIB();
|
---|
1426 | 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));
|
---|
1427 | break;
|
---|
1428 | // goto RunDefFrameWndProc;
|
---|
1429 | #endif
|
---|
1430 |
|
---|
1431 | case WM_FOCUSCHANGE:
|
---|
1432 | {
|
---|
1433 | HWND hwndFocus = (HWND)mp1;
|
---|
1434 | HWND hwndLoseFocus, hwndGainFocus;
|
---|
1435 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
---|
1436 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
---|
1437 |
|
---|
1438 | //Save window that gains focus so we can determine which
|
---|
1439 | //process we lose activation to
|
---|
1440 | hwndFocusChange = (HWND)mp1;
|
---|
1441 |
|
---|
1442 | dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x (%x) %x %x", win32wnd->getWindowHandle(), OS2ToWin32Handle(hwndFocus), hwndFocus, usSetFocus, fsFocusChange));
|
---|
1443 | goto RunDefFrameWndProc;
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | #ifdef DEBUG
|
---|
1447 | case WM_SETFOCUS:
|
---|
1448 | {
|
---|
1449 | dprintf(("PMFRAME: WM_SETFOCUS %x %x", win32wnd->getWindowHandle(), hwnd));
|
---|
1450 | goto RunDefFrameWndProc;
|
---|
1451 | }
|
---|
1452 | #endif
|
---|
1453 |
|
---|
1454 | case WM_ACTIVATE:
|
---|
1455 | {
|
---|
1456 | HWND hwndTitle;
|
---|
1457 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
---|
1458 |
|
---|
1459 | dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle((DWORD)mp2)));
|
---|
1460 | if (win32wnd->IsWindowCreated())
|
---|
1461 | {
|
---|
1462 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
1463 | if(fOS2Look) {
|
---|
1464 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
---|
1465 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, mp1, 0);
|
---|
1466 | }
|
---|
1467 | if(SHORT1FROMMP(mp1) == 0) {
|
---|
1468 | //deactivate
|
---|
1469 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
---|
1470 | }
|
---|
1471 | PID pidThis, pidPartner, pidTemp;
|
---|
1472 | TID tidPartner;
|
---|
1473 | HENUM henum;
|
---|
1474 | HWND hwndEnum;
|
---|
1475 |
|
---|
1476 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
---|
1477 | WinQueryWindowProcess(hwndFocusChange, &pidPartner, &tidPartner);
|
---|
1478 |
|
---|
1479 | if(pidThis != pidPartner) {
|
---|
1480 | //Gain or lose activation to window in other process
|
---|
1481 | //must send WM_ACTIVATEAPP to top-level windows
|
---|
1482 |
|
---|
1483 | //Iterate over all child windows of the desktop
|
---|
1484 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
---|
1485 |
|
---|
1486 | while(hwndEnum = WinGetNextWindow(henum))
|
---|
1487 | {
|
---|
1488 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
---|
1489 | if(pidTemp == pidThis)
|
---|
1490 | {
|
---|
1491 | SendMessageA(OS2ToWin32Handle(hwndEnum), WM_ACTIVATEAPP_W, (WPARAM)SHORT1FROMMP(mp1), (LPARAM)tidPartner);
|
---|
1492 | }
|
---|
1493 | }
|
---|
1494 | WinEndEnumWindows(henum);
|
---|
1495 | }
|
---|
1496 | if(SHORT1FROMMP(mp1)) {
|
---|
1497 | //activate
|
---|
1498 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | //CB: show owner behind the dialog
|
---|
1502 | if (win32wnd->IsModalDialog())
|
---|
1503 | {
|
---|
1504 | if(win32wnd->getOwner()) {
|
---|
1505 | Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
|
---|
1506 |
|
---|
1507 | if (topOwner) {
|
---|
1508 | WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
---|
1509 | RELEASE_WNDOBJ(topOwner);
|
---|
1510 | }
|
---|
1511 | }
|
---|
1512 | }
|
---|
1513 | }
|
---|
1514 | else
|
---|
1515 | {
|
---|
1516 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
1517 | }
|
---|
1518 | rc = 0;
|
---|
1519 | break;
|
---|
1520 | }
|
---|
1521 |
|
---|
1522 | case WM_ENABLE:
|
---|
1523 | dprintf(("PMFRAME: WM_ENABLE %x", hwnd));
|
---|
1524 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
---|
1525 | break;
|
---|
1526 |
|
---|
1527 | case WM_SHOW:
|
---|
1528 | dprintf(("PMFRAME: WM_SHOW %x %d", hwnd, mp1));
|
---|
1529 | //show client window
|
---|
1530 | WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
|
---|
1531 | break;
|
---|
1532 |
|
---|
1533 | case WM_QUERYTRACKINFO:
|
---|
1534 | {
|
---|
1535 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
---|
1536 |
|
---|
1537 | dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
---|
1538 | trackInfo->cxBorder = 4;
|
---|
1539 | trackInfo->cyBorder = 4;
|
---|
1540 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
---|
1541 | rc = (MRESULT)TRUE;
|
---|
1542 | break;
|
---|
1543 | }
|
---|
1544 |
|
---|
1545 | case WM_QUERYBORDERSIZE:
|
---|
1546 | {
|
---|
1547 | PWPOINT size = (PWPOINT)mp1;
|
---|
1548 |
|
---|
1549 | dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
---|
1550 |
|
---|
1551 | size->x = 0;
|
---|
1552 | size->y = 0;
|
---|
1553 | rc = (MRESULT)TRUE;
|
---|
1554 | break;
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | #ifdef DEBUG
|
---|
1558 | case WM_QUERYFRAMEINFO:
|
---|
1559 | dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
---|
1560 | goto RunDefFrameWndProc;
|
---|
1561 | #endif
|
---|
1562 |
|
---|
1563 | case WM_FORMATFRAME:
|
---|
1564 | dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
---|
1565 | break;
|
---|
1566 |
|
---|
1567 | #ifdef DEBUG
|
---|
1568 | case WM_ADJUSTFRAMEPOS:
|
---|
1569 | {
|
---|
1570 | PSWP pswp = (PSWP)mp1;
|
---|
1571 |
|
---|
1572 | dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1573 | goto RunDefFrameWndProc;
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 | case WM_OWNERPOSCHANGE:
|
---|
1577 | {
|
---|
1578 | PSWP pswp = (PSWP)mp1;
|
---|
1579 |
|
---|
1580 | dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
1581 | goto RunDefFrameWndProc;
|
---|
1582 | }
|
---|
1583 | #endif
|
---|
1584 |
|
---|
1585 | case WM_MINMAXFRAME:
|
---|
1586 | {
|
---|
1587 | PSWP swp = (PSWP)mp1;
|
---|
1588 |
|
---|
1589 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
---|
1590 |
|
---|
1591 | dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
|
---|
1592 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
---|
1593 | {
|
---|
1594 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
---|
1595 |
|
---|
1596 | RECT rect;
|
---|
1597 |
|
---|
1598 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
---|
1599 | win32wnd->AdjustMaximizedRect(&rect);
|
---|
1600 | swp->x += rect.left;
|
---|
1601 | swp->cx += rect.right-rect.left;
|
---|
1602 | swp->y -= rect.bottom;
|
---|
1603 | swp->cy += rect.bottom-rect.top;
|
---|
1604 | }
|
---|
1605 | else
|
---|
1606 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
---|
1607 | {
|
---|
1608 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
---|
1609 | }
|
---|
1610 | else
|
---|
1611 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
---|
1612 | {
|
---|
1613 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
---|
1614 | }
|
---|
1615 | goto RunDefWndProc;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | #ifdef DEBUG
|
---|
1619 | case WM_UPDATEFRAME:
|
---|
1620 | dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
---|
1621 | goto RunDefFrameWndProc;
|
---|
1622 | #endif
|
---|
1623 |
|
---|
1624 | case WM_TRACKFRAME:
|
---|
1625 | dprintf(("PMFRAME: WM_TRACKFRAME %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
1626 | if(fOS2Look) {//sent by titlebar control
|
---|
1627 | #ifdef CUSTOM_TRACKFRAME
|
---|
1628 | Frame_SysCommandSizeMove(win32wnd, SC_MOVE_W+HTCAPTION_W);
|
---|
1629 | #else
|
---|
1630 | FrameTrackFrame(win32wnd, TF_MOVE);
|
---|
1631 | #endif
|
---|
1632 | }
|
---|
1633 | rc = 0;
|
---|
1634 | break;
|
---|
1635 |
|
---|
1636 | case WM_SYSCOMMAND:
|
---|
1637 | dprintf(("PMFRAME: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
---|
1638 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
1639 | RELEASE_WNDOBJ(win32wnd);
|
---|
1640 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
1641 | }
|
---|
1642 | if(win32wnd)
|
---|
1643 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
1644 | break;
|
---|
1645 |
|
---|
1646 | #ifdef DEBUG
|
---|
1647 | case WM_DDE_INITIATE:
|
---|
1648 | case WM_DDE_INITIATEACK:
|
---|
1649 | case WM_DDE_REQUEST:
|
---|
1650 | case WM_DDE_ACK:
|
---|
1651 | case WM_DDE_DATA:
|
---|
1652 | case WM_DDE_ADVISE:
|
---|
1653 | case WM_DDE_UNADVISE:
|
---|
1654 | case WM_DDE_POKE:
|
---|
1655 | case WM_DDE_EXECUTE:
|
---|
1656 | case WM_DDE_TERMINATE:
|
---|
1657 | dprintf(("PMFRAME: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
---|
1658 | break;
|
---|
1659 | #endif
|
---|
1660 |
|
---|
1661 | default:
|
---|
1662 | goto RunDefFrameWndProc;
|
---|
1663 | }
|
---|
1664 | RestoreOS2TIB();
|
---|
1665 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
1666 | return (MRESULT)rc;
|
---|
1667 |
|
---|
1668 | RunDefFrameWndProc:
|
---|
1669 | dprintf2(("RunDefFrameWndProc"));
|
---|
1670 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
1671 | RestoreOS2TIB();
|
---|
1672 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
1673 |
|
---|
1674 | RunDefWndProc:
|
---|
1675 | dprintf2(("RunDefWndProc"));
|
---|
1676 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
1677 | RestoreOS2TIB();
|
---|
1678 | //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
|
---|
1679 | // return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
---|
1680 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
1681 | }
|
---|
1682 | //******************************************************************************
|
---|
1683 | //******************************************************************************
|
---|
1684 | void FrameSetFocus(HWND hwnd)
|
---|
1685 | {
|
---|
1686 | HWND hwndFocusSave = WinQueryWindowULong(hwnd, QWL_HWNDFOCUSSAVE);
|
---|
1687 | if(!WinIsWindow(hab, hwndFocusSave)) {
|
---|
1688 | hwndFocusSave = WinWindowFromID(hwnd, FID_CLIENT);
|
---|
1689 | WinSetWindowULong(hwnd, QWL_HWNDFOCUSSAVE, hwndFocusSave);
|
---|
1690 | }
|
---|
1691 | dprintf(("FrameSetFocus: hwndFocusSave %x %x", OS2ToWin32Handle(hwndFocusSave), hwndFocusSave));
|
---|
1692 | WinSetFocus(HWND_DESKTOP, hwndFocusSave);
|
---|
1693 |
|
---|
1694 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
---|
1695 | ulFrameFlags &= ~FF_NOACTIVATESWP;
|
---|
1696 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags);
|
---|
1697 | }
|
---|
1698 | #ifndef CUSTOM_TRACKFRAME
|
---|
1699 | //******************************************************************************
|
---|
1700 | //TODO: Quickly moving a window two times doesn't force a repaint (1st time)
|
---|
1701 | //
|
---|
1702 | //
|
---|
1703 | BOOL (APIENTRY *WinTrackWindow)(HWND hwndTrack, PTRACKINFO pti) = NULL;
|
---|
1704 | //
|
---|
1705 | //******************************************************************************
|
---|
1706 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
---|
1707 | {
|
---|
1708 | TRACKINFO track;
|
---|
1709 | RECTL rcl;
|
---|
1710 | PRECT pWindowRect, pClientRect;
|
---|
1711 | HWND hwndTracking;
|
---|
1712 | LONG parentHeight, parentWidth;
|
---|
1713 | static BOOL fInit = FALSE;
|
---|
1714 | APIRET rc;
|
---|
1715 | BOOL ret;
|
---|
1716 | HWND hwnd = win32wnd->getWindowHandle();
|
---|
1717 |
|
---|
1718 | if(!fInit) {
|
---|
1719 | HMODULE hModule;
|
---|
1720 | char buf[CCHMAXPATH];
|
---|
1721 | rc = DosLoadModule(buf, sizeof(buf), "PMMERGE", &hModule);
|
---|
1722 | rc = DosQueryProcAddr(hModule, 5466, NULL, (PFN *)&WinTrackWindow);
|
---|
1723 | if(rc) WinTrackWindow = NULL;
|
---|
1724 | fInit = TRUE;
|
---|
1725 | }
|
---|
1726 | dprintf(("FrameTrackFrame: %x %x", hwnd, flags));
|
---|
1727 | track.cxBorder = 4;
|
---|
1728 | track.cyBorder = 4; /* 4 pel wide lines used for rectangle */
|
---|
1729 | track.cxGrid = 1;
|
---|
1730 | track.cyGrid = 1; /* smooth tracking with mouse */
|
---|
1731 | track.cxKeyboard = 8;
|
---|
1732 | track.cyKeyboard = 8; /* faster tracking using cursor keys */
|
---|
1733 |
|
---|
1734 | pWindowRect = win32wnd->getWindowRect();
|
---|
1735 | if(win32wnd->getParent()) {
|
---|
1736 | parentHeight = win32wnd->getParent()->getClientHeight();
|
---|
1737 | parentWidth = win32wnd->getParent()->getClientWidth();
|
---|
1738 | hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
|
---|
1739 | }
|
---|
1740 | else {
|
---|
1741 | parentHeight = OSLibQueryScreenHeight();
|
---|
1742 | parentWidth = OSLibQueryScreenWidth();
|
---|
1743 | hwndTracking = HWND_DESKTOP;
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 | mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
|
---|
1747 | rcl = track.rclTrack;
|
---|
1748 | WinQueryWindowRect(hwndTracking, &track.rclBoundary);
|
---|
1749 |
|
---|
1750 | track.ptlMinTrackSize.x = 10;
|
---|
1751 | track.ptlMinTrackSize.y = 10; /* set smallest allowed size of rectangle */
|
---|
1752 | track.ptlMaxTrackSize.x = parentWidth;
|
---|
1753 | track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
|
---|
1754 |
|
---|
1755 | win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
|
---|
1756 |
|
---|
1757 | track.fs = flags;
|
---|
1758 |
|
---|
1759 | BOOL fDynamicDrag = WinQuerySysValue(HWND_DESKTOP, SVOS_DYNAMICDRAG);
|
---|
1760 |
|
---|
1761 | //TODO: send WM_QUERYDRAGICON to fetch icon (not really necessary)
|
---|
1762 |
|
---|
1763 | SendMessageA( hwnd, WM_ENTERSIZEMOVE_W, 0, 0);
|
---|
1764 |
|
---|
1765 | SEL sel = RestoreOS2FS();
|
---|
1766 | if(fDynamicDrag && WinTrackWindow) {
|
---|
1767 | ret = WinTrackWindow(win32wnd->getOS2FrameWindowHandle(), &track);
|
---|
1768 | }
|
---|
1769 | else ret = WinTrackRect(hwndTracking, NULL, &track);
|
---|
1770 | SetFS(sel);
|
---|
1771 |
|
---|
1772 | //TODO:
|
---|
1773 | // if (HOOK_CallHooksA( WH_CBT_W, HCBT_MOVESIZE_W, (WPARAM)hwnd, (LPARAM)&sizingRect )) moved = FALSE;
|
---|
1774 |
|
---|
1775 | SendMessageA( hwnd, WM_EXITSIZEMOVE_W, 0, 0 );
|
---|
1776 | SendMessageA( hwnd, WM_SETVISIBLE_W, !IsIconic(hwnd), 0L);
|
---|
1777 |
|
---|
1778 | if(ret) {
|
---|
1779 | /* if successful copy final position back */
|
---|
1780 | if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
|
---|
1781 | dprintf(("FrameTrackFrame: new (os/2) window rect: (%d,%d)(%d,%d)", track.rclTrack.xLeft, track.rclTrack.yBottom, track.rclTrack.xRight - track.rclTrack.xLeft, track.rclTrack.yTop - track.rclTrack.yBottom));
|
---|
1782 | if(flags == TF_MOVE) {
|
---|
1783 | WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
|
---|
1784 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
---|
1785 | 0, 0, SWP_MOVE);
|
---|
1786 | }
|
---|
1787 | else {
|
---|
1788 | WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
|
---|
1789 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
---|
1790 | track.rclTrack.xRight - track.rclTrack.xLeft,
|
---|
1791 | track.rclTrack.yTop - track.rclTrack.yBottom,
|
---|
1792 | SWP_SIZE|SWP_MOVE);
|
---|
1793 | }
|
---|
1794 | }
|
---|
1795 | return;
|
---|
1796 | }
|
---|
1797 | return;
|
---|
1798 | }
|
---|
1799 | #endif
|
---|
1800 | //******************************************************************************
|
---|
1801 | //******************************************************************************
|
---|
1802 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
---|
1803 | HBITMAP hbmNew)
|
---|
1804 | {
|
---|
1805 | MENUITEM mi;
|
---|
1806 |
|
---|
1807 | if (!hwndMenu)
|
---|
1808 | return;
|
---|
1809 |
|
---|
1810 | WinEnableWindowUpdate(hwndMenu, FALSE);
|
---|
1811 |
|
---|
1812 | if (WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(idOld, TRUE), MPFROMP(&mi)))
|
---|
1813 | {
|
---|
1814 | WinSendMsg(hwndMenu, MM_REMOVEITEM, (MPARAM)idOld, 0);
|
---|
1815 | mi.afStyle = MIS_BITMAP | MIS_SYSCOMMAND;
|
---|
1816 | mi.afAttribute = 0;
|
---|
1817 | mi.hwndSubMenu = 0;
|
---|
1818 | mi.id = idNew;
|
---|
1819 | mi.hItem = (ULONG)hbmNew;
|
---|
1820 | WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, 0);
|
---|
1821 | }
|
---|
1822 | WinEnableWindowUpdate(hwndMenu, TRUE);
|
---|
1823 |
|
---|
1824 | WinInvalidateRect(hwndMenu, NULL, TRUE);
|
---|
1825 | }
|
---|
1826 | //******************************************************************************
|
---|
1827 | //******************************************************************************
|
---|