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