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