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