1 | /* $Id: pmframe.cpp,v 1.52 2000-04-29 18:28:38 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Frame Managment Code for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1999 by Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
6 | *
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | #define INCL_WIN
|
---|
13 | #define INCL_GPI
|
---|
14 |
|
---|
15 | #include <os2wrap.h>
|
---|
16 | #include <stdlib.h>
|
---|
17 | #include <string.h>
|
---|
18 | #include <win32type.h>
|
---|
19 | #include <winconst.h>
|
---|
20 | #include <misc.h>
|
---|
21 | #include <win32wbase.h>
|
---|
22 | #include "wprocess.h"
|
---|
23 | #include "pmframe.h"
|
---|
24 | #include "oslibutil.h"
|
---|
25 | #include "oslibwin.h"
|
---|
26 | #include "caret.h"
|
---|
27 | #include "oslibmsg.h"
|
---|
28 |
|
---|
29 | #define DBG_LOCALLOG DBG_pmframe
|
---|
30 | #include "dbglocal.h"
|
---|
31 |
|
---|
32 | #define PMFRAMELOG
|
---|
33 |
|
---|
34 | //******************************************************************************
|
---|
35 | //******************************************************************************
|
---|
36 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
---|
37 | {
|
---|
38 | WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
|
---|
39 | }
|
---|
40 | //******************************************************************************
|
---|
41 | //******************************************************************************
|
---|
42 | VOID FrameUpdateChildPositions(HWND hwnd)
|
---|
43 | {
|
---|
44 | HENUM henum;
|
---|
45 | HWND hchild;
|
---|
46 | RECTL rectl;
|
---|
47 |
|
---|
48 | henum = WinBeginEnumWindows(hwnd);
|
---|
49 | while ((hchild = WinGetNextWindow(henum)) != NULLHANDLE)
|
---|
50 | {
|
---|
51 | Win32BaseWindow *child = Win32BaseWindow::GetWindowFromOS2FrameHandle(hchild);
|
---|
52 |
|
---|
53 | if (child)
|
---|
54 | {
|
---|
55 | WinQueryWindowRect(child->getOS2FrameWindowHandle(),&rectl);
|
---|
56 | mapOS2ToWin32Rect(child->getOS2FrameWindowHandle(),OSLIB_HWND_DESKTOP,(PRECTLOS2)&rectl,child->getWindowRect());
|
---|
57 | FrameUpdateChildPositions(child->getOS2WindowHandle());
|
---|
58 | }
|
---|
59 | }
|
---|
60 | WinEndEnumWindows(henum);
|
---|
61 | }
|
---|
62 | //******************************************************************************
|
---|
63 | //Win32 frame message handler
|
---|
64 | //******************************************************************************
|
---|
65 | MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
---|
66 | {
|
---|
67 | Win32BaseWindow *win32wnd;
|
---|
68 | PFNWP OldFrameProc;
|
---|
69 | MRESULT rc;
|
---|
70 | THDB *thdb;
|
---|
71 | MSG *pWinMsg,winMsg;
|
---|
72 |
|
---|
73 | SetWin32TIB();
|
---|
74 |
|
---|
75 | thdb = GetThreadTHDB();
|
---|
76 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
---|
77 |
|
---|
78 | if (!thdb || (win32wnd == NULL) || !win32wnd->getOldFrameProc())
|
---|
79 | {
|
---|
80 | dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
|
---|
81 | goto RunDefWndProc;
|
---|
82 | }
|
---|
83 |
|
---|
84 | if((thdb->msgstate & 1) == 0)
|
---|
85 | {//message that was sent directly to our window proc handler; translate it here
|
---|
86 | QMSG qmsg;
|
---|
87 |
|
---|
88 | qmsg.msg = msg;
|
---|
89 | qmsg.hwnd = hwnd;
|
---|
90 | qmsg.mp1 = mp1;
|
---|
91 | qmsg.mp2 = mp2;
|
---|
92 | qmsg.time = WinQueryMsgTime(thdb->hab);
|
---|
93 | WinQueryMsgPos(thdb->hab, &qmsg.ptl);
|
---|
94 | qmsg.reserved = 0;
|
---|
95 |
|
---|
96 | if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
---|
97 | {//message was not translated
|
---|
98 | memset(&winMsg, 0, sizeof(MSG));
|
---|
99 | }
|
---|
100 | pWinMsg = &winMsg;
|
---|
101 | }
|
---|
102 | else {
|
---|
103 | pWinMsg = &thdb->msg;
|
---|
104 | thdb->msgstate++;
|
---|
105 | }
|
---|
106 |
|
---|
107 | OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
|
---|
108 |
|
---|
109 | switch(msg)
|
---|
110 | {
|
---|
111 | case WM_FORMATFRAME:
|
---|
112 | break;
|
---|
113 |
|
---|
114 | case WM_MINMAXFRAME:
|
---|
115 | {
|
---|
116 | PSWP swp = (PSWP)mp1;
|
---|
117 |
|
---|
118 | if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
|
---|
119 | dprintf(("PMFRAME: WM_MINMAXFRAME %x",hwnd));
|
---|
120 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
---|
121 | {
|
---|
122 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
---|
123 |
|
---|
124 | RECT rect;
|
---|
125 |
|
---|
126 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
---|
127 | win32wnd->AdjustMaximizedRect(&rect);
|
---|
128 | swp->x += rect.left;
|
---|
129 | swp->cx += rect.right-rect.left;
|
---|
130 | swp->y -= rect.bottom;
|
---|
131 | swp->cy += rect.bottom-rect.top;
|
---|
132 | }
|
---|
133 | else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
---|
134 | {
|
---|
135 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
---|
136 | }
|
---|
137 | else if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
---|
138 | {
|
---|
139 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
---|
140 | }
|
---|
141 | goto RunDefFrameProc;
|
---|
142 | }
|
---|
143 |
|
---|
144 | case WM_QUERYTRACKINFO:
|
---|
145 | {
|
---|
146 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
---|
147 |
|
---|
148 | RestoreOS2TIB();
|
---|
149 | OldFrameProc(hwnd,msg,mp1,mp2);
|
---|
150 | SetWin32TIB();
|
---|
151 | trackInfo->cxBorder = 4;
|
---|
152 | trackInfo->cyBorder = 4;
|
---|
153 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
---|
154 | RestoreOS2TIB();
|
---|
155 | return (MRESULT)TRUE;
|
---|
156 | }
|
---|
157 |
|
---|
158 | case WM_QUERYBORDERSIZE:
|
---|
159 | {
|
---|
160 | PWPOINT size = (PWPOINT)mp1;
|
---|
161 |
|
---|
162 | size->x = 0;
|
---|
163 | size->y = 0;
|
---|
164 | RestoreOS2TIB();
|
---|
165 | return (MRESULT)TRUE;
|
---|
166 | }
|
---|
167 |
|
---|
168 | case WM_HITTEST:
|
---|
169 | {
|
---|
170 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
171 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
172 | }
|
---|
173 | if(win32wnd && win32wnd->IsWindowCreated())
|
---|
174 | {
|
---|
175 | MRESULT rc;
|
---|
176 |
|
---|
177 | rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
|
---|
178 | RestoreOS2TIB();
|
---|
179 | return rc;
|
---|
180 | }
|
---|
181 | return (MRESULT)HT_NORMAL;
|
---|
182 | }
|
---|
183 |
|
---|
184 | case WM_BUTTON1DOWN:
|
---|
185 | case WM_BUTTON1UP:
|
---|
186 | case WM_BUTTON1DBLCLK:
|
---|
187 | case WM_BUTTON2DOWN:
|
---|
188 | case WM_BUTTON2UP:
|
---|
189 | case WM_BUTTON2DBLCLK:
|
---|
190 | case WM_BUTTON3DOWN:
|
---|
191 | case WM_BUTTON3UP:
|
---|
192 | case WM_BUTTON3DBLCLK:
|
---|
193 | {
|
---|
194 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
195 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
196 | }
|
---|
197 | if(win32wnd && win32wnd->IsWindowCreated())
|
---|
198 | {
|
---|
199 | win32wnd->MsgButton(pWinMsg);
|
---|
200 | RestoreOS2TIB();
|
---|
201 | }
|
---|
202 | return (MRESULT)TRUE;
|
---|
203 | }
|
---|
204 |
|
---|
205 | case WM_BUTTON2MOTIONSTART:
|
---|
206 | case WM_BUTTON2MOTIONEND:
|
---|
207 | case WM_BUTTON2CLICK:
|
---|
208 | case WM_BUTTON1MOTIONSTART:
|
---|
209 | case WM_BUTTON1MOTIONEND:
|
---|
210 | case WM_BUTTON1CLICK:
|
---|
211 | case WM_BUTTON3MOTIONSTART:
|
---|
212 | case WM_BUTTON3MOTIONEND:
|
---|
213 | case WM_BUTTON3CLICK:
|
---|
214 | RestoreOS2TIB();
|
---|
215 | return (MRESULT)TRUE;
|
---|
216 |
|
---|
217 | case WM_MOUSEMOVE:
|
---|
218 | {
|
---|
219 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
---|
220 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
---|
221 | }
|
---|
222 | if(win32wnd && win32wnd->IsWindowCreated())
|
---|
223 | win32wnd->MsgMouseMove(pWinMsg);
|
---|
224 | RestoreOS2TIB();
|
---|
225 | return (MRESULT)TRUE;
|
---|
226 | }
|
---|
227 |
|
---|
228 | case WM_PAINT:
|
---|
229 | {
|
---|
230 | dprintf(("PMFRAME: WM_PAINT"));
|
---|
231 | if (win32wnd->getStyle() & WS_MINIMIZE_W)
|
---|
232 | goto RunDefFrameProc;
|
---|
233 | if (win32wnd->IsWindowCreated())
|
---|
234 | win32wnd->MsgNCPaint();
|
---|
235 | goto RunDefWndProc;
|
---|
236 | }
|
---|
237 |
|
---|
238 | case WM_SIZE:
|
---|
239 | dprintf(("PMFRAME: WM_SIZE"));
|
---|
240 | goto RunDefFrameProc;
|
---|
241 |
|
---|
242 | case WM_ADJUSTWINDOWPOS:
|
---|
243 | {
|
---|
244 | PSWP pswp = (PSWP)mp1;
|
---|
245 | SWP swpOld;
|
---|
246 | WINDOWPOS wp,wpOld;
|
---|
247 | HWND hParent = NULLHANDLE, hwndAfter;
|
---|
248 |
|
---|
249 | 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));
|
---|
250 |
|
---|
251 | //CB: show dialog in front of owner
|
---|
252 | if (win32wnd->IsModalDialogOwner())
|
---|
253 | {
|
---|
254 | pswp->fl |= SWP_ZORDER;
|
---|
255 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
---|
256 | if (pswp->fl & SWP_ACTIVATE)
|
---|
257 | {
|
---|
258 | pswp->fl &= ~SWP_ACTIVATE;
|
---|
259 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
---|
260 | }
|
---|
261 | }
|
---|
262 |
|
---|
263 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
---|
264 | goto RunDefFrameProc;
|
---|
265 |
|
---|
266 | if(!win32wnd->CanReceiveSizeMsgs())
|
---|
267 | break;
|
---|
268 |
|
---|
269 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
270 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
271 | if (win32wnd->isChild()) {
|
---|
272 | if(win32wnd->getParent()) {
|
---|
273 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
274 | }
|
---|
275 | else goto RunDefFrameProc;
|
---|
276 | }
|
---|
277 | }
|
---|
278 | hwndAfter = pswp->hwndInsertBehind;
|
---|
279 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
---|
280 |
|
---|
281 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
282 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
283 | {
|
---|
284 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
285 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
286 | }
|
---|
287 |
|
---|
288 | wpOld = wp;
|
---|
289 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
---|
290 |
|
---|
291 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
---|
292 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
---|
293 | {
|
---|
294 | dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
---|
295 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
296 |
|
---|
297 | OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
|
---|
298 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
299 | pswp->fl |= SWP_NOADJUST;
|
---|
300 | pswp->hwndInsertBehind = hwndAfter;
|
---|
301 | pswp->hwnd = hwnd;
|
---|
302 |
|
---|
303 | RestoreOS2TIB();
|
---|
304 | return (MRESULT)0xf;
|
---|
305 | }
|
---|
306 | RestoreOS2TIB();
|
---|
307 | return (MRESULT)0;
|
---|
308 | }
|
---|
309 |
|
---|
310 | case WM_WINDOWPOSCHANGED:
|
---|
311 | {
|
---|
312 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
---|
313 | SWP swpOld = *(pswp + 1);
|
---|
314 | WINDOWPOS wp;
|
---|
315 | HWND hParent = NULLHANDLE;
|
---|
316 | RECTL rect;
|
---|
317 | SWP swpClient = {0};
|
---|
318 |
|
---|
319 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
320 |
|
---|
321 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
---|
322 | {
|
---|
323 | goto RunDefFrameProc;
|
---|
324 | }
|
---|
325 |
|
---|
326 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
327 | if (win32wnd->isChild()) {
|
---|
328 | if(win32wnd->getParent()) {
|
---|
329 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
330 | }
|
---|
331 | else goto PosChangedEnd; //parent has just been destroyed
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
|
---|
336 |
|
---|
337 | if(pswp->fl & SWP_ACTIVATE)
|
---|
338 | {
|
---|
339 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
---|
340 | }
|
---|
341 |
|
---|
342 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
|
---|
343 | {
|
---|
344 | //Note: Also updates the new window rectangle
|
---|
345 | win32wnd->MsgFormatFrame(&wp);
|
---|
346 |
|
---|
347 | //CB: todo: use result for WM_CALCVALIDRECTS
|
---|
348 | mapWin32ToOS2Rect(win32wnd->getOS2FrameWindowHandle(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
---|
349 |
|
---|
350 | swpClient.hwnd = win32wnd->getOS2WindowHandle();
|
---|
351 | swpClient.hwndInsertBehind = 0;
|
---|
352 | swpClient.x = rect.xLeft;
|
---|
353 | swpClient.y = rect.yBottom;
|
---|
354 | swpClient.cx = rect.xRight-rect.xLeft;
|
---|
355 | swpClient.cy = rect.yTop-rect.yBottom;
|
---|
356 | //TODO: Get rid of SWP_SHOW; needed for winhlp32 button bar for now
|
---|
357 | swpClient.fl = (pswp->fl & ~SWP_ZORDER) | SWP_MOVE | SWP_SHOW;
|
---|
358 | WinSetMultWindowPos(thdb->hab, &swpClient, 1);
|
---|
359 |
|
---|
360 | //update child positions: rectWindow is in window coordinates
|
---|
361 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
362 | FrameUpdateChildPositions(win32wnd->getOS2WindowHandle());
|
---|
363 | }
|
---|
364 |
|
---|
365 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
366 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
367 |
|
---|
368 | if ((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
---|
369 | {
|
---|
370 | //redraw the frame (to prevent unnecessary client updates)
|
---|
371 | BOOL redrawAll = FALSE;
|
---|
372 |
|
---|
373 | if (win32wnd->getWindowClass())
|
---|
374 | {
|
---|
375 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
---|
376 |
|
---|
377 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
---|
378 | redrawAll = TRUE;
|
---|
379 | else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
---|
380 | redrawAll = TRUE;
|
---|
381 | } else redrawAll = TRUE;
|
---|
382 |
|
---|
383 | if (redrawAll)
|
---|
384 | {
|
---|
385 | //CB: redraw all children for now
|
---|
386 | // -> problems with update region if we don't do it
|
---|
387 | // todo: rewrite whole handling
|
---|
388 | WinInvalidateRect(hwnd,NULL,TRUE);
|
---|
389 | }
|
---|
390 | else
|
---|
391 | {
|
---|
392 | HPS hps = WinGetPS(hwnd);
|
---|
393 | RECTL frame,client,arcl[4];
|
---|
394 |
|
---|
395 | WinQueryWindowRect(hwnd,&frame);
|
---|
396 | //top
|
---|
397 | arcl[0].xLeft = 0;
|
---|
398 | arcl[0].xRight = frame.xRight;
|
---|
399 | arcl[0].yBottom = rect.yTop;
|
---|
400 | arcl[0].yTop = frame.yTop;
|
---|
401 | //right
|
---|
402 | arcl[1].xLeft = rect.xRight;
|
---|
403 | arcl[1].xRight = frame.xRight;
|
---|
404 | arcl[1].yBottom = 0;
|
---|
405 | arcl[1].yTop = frame.yTop;
|
---|
406 | //left
|
---|
407 | arcl[2].xLeft = 0;
|
---|
408 | arcl[2].xRight = rect.xLeft;
|
---|
409 | arcl[2].yBottom = 0;
|
---|
410 | arcl[2].yTop = frame.yTop;
|
---|
411 | //bottom
|
---|
412 | arcl[3].xLeft = 0;
|
---|
413 | arcl[3].xRight = frame.xRight;
|
---|
414 | arcl[3].yBottom = 0;
|
---|
415 | arcl[3].yTop = rect.yBottom;
|
---|
416 |
|
---|
417 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
---|
418 |
|
---|
419 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
---|
420 | GpiDestroyRegion(hps,hrgn);
|
---|
421 | WinReleasePS(hps);
|
---|
422 | }
|
---|
423 | }
|
---|
424 | }
|
---|
425 | else
|
---|
426 | {
|
---|
427 | //update child positions: rectWindow is in window coordinates
|
---|
428 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
429 | FrameUpdateChildPositions(win32wnd->getOS2WindowHandle());
|
---|
430 | }
|
---|
431 |
|
---|
432 | if(win32wnd->CanReceiveSizeMsgs())
|
---|
433 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
434 | }
|
---|
435 |
|
---|
436 | PosChangedEnd:
|
---|
437 | RestoreOS2TIB();
|
---|
438 | return (MRESULT)FALSE;
|
---|
439 | }
|
---|
440 |
|
---|
441 | case WM_SHOW:
|
---|
442 | dprintf(("PMFRAME: WM_SHOW"));
|
---|
443 | break;
|
---|
444 |
|
---|
445 | case WM_ERASEBACKGROUND:
|
---|
446 | break;
|
---|
447 |
|
---|
448 | case WM_CALCVALIDRECTS:
|
---|
449 | {
|
---|
450 | //don't redraw here or PM redraw the whole frame (done in WM_WINDOWPOSCHANGED)
|
---|
451 | dprintf(("PMFRAME: WM_CALCVALIDRECTS"));
|
---|
452 | RestoreOS2TIB();
|
---|
453 | return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
---|
454 | }
|
---|
455 |
|
---|
456 | case WM_ACTIVATE:
|
---|
457 | {
|
---|
458 | HWND hwndTitle;
|
---|
459 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
---|
460 |
|
---|
461 | dprintf(("PMFRAME: WM_ACTIVATE %x %x", hwnd, mp2));
|
---|
462 | if(win32wnd->IsWindowCreated())
|
---|
463 | win32wnd->DispatchMsgA(pWinMsg);
|
---|
464 |
|
---|
465 | if (win32wnd->IsWindowCreated())
|
---|
466 | {
|
---|
467 | WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
|
---|
468 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
469 |
|
---|
470 | //CB: show owner behind the dialog
|
---|
471 | if (win32wnd->IsModalDialog())
|
---|
472 | {
|
---|
473 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
---|
474 |
|
---|
475 | if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
---|
476 | }
|
---|
477 | }
|
---|
478 | else
|
---|
479 | {
|
---|
480 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
---|
481 | }
|
---|
482 | RestoreOS2TIB();
|
---|
483 | return 0;
|
---|
484 | }
|
---|
485 |
|
---|
486 | case WM_DESTROY:
|
---|
487 | dprintf(("PMFRAME: WM_DESTROY %x",hwnd));
|
---|
488 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
---|
489 | WinSubclassWindow(hwnd,OldFrameProc);
|
---|
490 | win32wnd->setOldFrameProc(NULL);
|
---|
491 | goto RunDefFrameProc;
|
---|
492 |
|
---|
493 | case WM_VRNENABLED:
|
---|
494 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
---|
495 | {
|
---|
496 | HWND hwndrelated;
|
---|
497 | Win32BaseWindow *topwindow;
|
---|
498 |
|
---|
499 | win32wnd->setComingToTop(TRUE);
|
---|
500 |
|
---|
501 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
---|
502 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
---|
503 | topwindow = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndrelated);
|
---|
504 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
---|
505 | //put window at the top of z order
|
---|
506 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
---|
507 | }
|
---|
508 |
|
---|
509 | win32wnd->setComingToTop(FALSE);
|
---|
510 | break;
|
---|
511 | }
|
---|
512 | goto RunDefFrameProc;
|
---|
513 |
|
---|
514 | default:
|
---|
515 | RestoreOS2TIB();
|
---|
516 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
---|
517 | }
|
---|
518 |
|
---|
519 | RestoreOS2TIB();
|
---|
520 | return (MRESULT)FALSE;
|
---|
521 |
|
---|
522 | RunDefFrameProc:
|
---|
523 | RestoreOS2TIB();
|
---|
524 | return OldFrameProc(hwnd,msg,mp1,mp2);
|
---|
525 |
|
---|
526 | RunDefWndProc:
|
---|
527 | RestoreOS2TIB();
|
---|
528 | return WinDefWindowProc(hwnd,msg,mp1,mp2);
|
---|
529 | }
|
---|
530 | //******************************************************************************
|
---|
531 | //******************************************************************************
|
---|
532 | PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
|
---|
533 | {
|
---|
534 | return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
|
---|
535 | }
|
---|
536 | //******************************************************************************
|
---|
537 | //******************************************************************************
|
---|
538 | VOID FrameUpdateClient(Win32BaseWindow *win32wnd)
|
---|
539 | {
|
---|
540 | RECT rectOld, rectNew;
|
---|
541 | RECTL rect;
|
---|
542 | SWP swpClient = {0};
|
---|
543 |
|
---|
544 | rectOld = *win32wnd->getClientRectPtr();
|
---|
545 | win32wnd->MsgFormatFrame(NULL);
|
---|
546 | rectNew = *win32wnd->getClientRectPtr();
|
---|
547 | if(WinEqualRect(0, (PRECTL)&rectOld, (PRECTL)&rectNew) == 1) {
|
---|
548 | WinInvalidateRect(win32wnd->getOS2FrameWindowHandle(), NULL, FALSE);
|
---|
549 | return;
|
---|
550 | }
|
---|
551 | //CB: todo: use result for WM_CALCVALIDRECTS
|
---|
552 | mapWin32ToOS2Rect(win32wnd->getOS2FrameWindowHandle(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
---|
553 |
|
---|
554 |
|
---|
555 | swpClient.hwnd = win32wnd->getOS2WindowHandle();
|
---|
556 | swpClient.hwndInsertBehind = 0;
|
---|
557 | swpClient.x = rect.xLeft;
|
---|
558 | swpClient.y = rect.yBottom;
|
---|
559 | swpClient.cx = rect.xRight-rect.xLeft;
|
---|
560 | swpClient.cy = rect.yTop-rect.yBottom;
|
---|
561 | swpClient.fl = SWP_MOVE | SWP_SIZE;
|
---|
562 | WinSetMultWindowPos(GetThreadHAB(), &swpClient, 1);
|
---|
563 | }
|
---|
564 | //******************************************************************************
|
---|
565 | //******************************************************************************
|
---|