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