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