source: trunk/src/user32/pmframe.cpp@ 2200

Last change on this file since 2200 was 2200, checked in by sandervl, 26 years ago

Message handling rewrite

File size: 22.2 KB
Line 
1/* $Id: pmframe.cpp,v 1.29 1999-12-24 18:39:10 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 <os2.h> /* PM header file */
16#include <os2wrap.h>
17#include <stdlib.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
27#define PMFRAMELOG
28
29//******************************************************************************
30//******************************************************************************
31VOID Draw3DRect(HPS hps,RECTL rect,LONG colorBR,LONG colorTL)
32{
33 POINTL point;
34
35 GpiSetColor(hps,colorBR);
36 point.x = rect.xLeft;
37 point.y = rect.yBottom;
38 GpiMove(hps,&point);
39 point.x = rect.xRight-1;
40 GpiLine(hps,&point);
41 point.y = rect.yTop-1;
42 GpiLine(hps,&point);
43 GpiSetColor(hps,colorTL);
44 point.x--;
45 GpiMove(hps,&point);
46 point.x = rect.xLeft;
47 GpiLine(hps,&point);
48 point.y = rect.yBottom+1;
49 GpiLine(hps,&point);
50}
51//******************************************************************************
52//******************************************************************************
53inline VOID DeflateRect(RECTL *rect)
54{
55 rect->xLeft++;
56 rect->xRight--;
57 rect->yTop--;
58 rect->yBottom++;
59}
60//******************************************************************************
61//******************************************************************************
62VOID DrawFrame(HPS hps,RECTL *rect,Win32BaseWindow *win32wnd)
63{
64 LONG clrWhite,clrBlack,clrDark,clrLight;
65 POINTL point;
66 DWORD dwExStyle = win32wnd->getExStyle();
67 DWORD dwStyle = win32wnd->getStyle();
68
69 //CB: todo: switch to RGB mode and use win colors
70 clrWhite = CLR_WHITE;
71 clrBlack = CLR_BLACK;
72 clrLight = CLR_PALEGRAY;
73 clrDark = CLR_DARKGRAY;
74
75 if (dwExStyle & WS_EX_CLIENTEDGE_W)
76 {
77 Draw3DRect(hps,*rect,clrWhite,clrDark);
78 DeflateRect(rect);
79 Draw3DRect(hps,*rect,clrLight,clrBlack);
80 }
81 else if (dwExStyle & WS_EX_DLGMODALFRAME_W)
82 {
83 Draw3DRect(hps,*rect,clrBlack,clrLight);
84 DeflateRect(rect);
85 Draw3DRect(hps,*rect,clrDark,clrWhite);
86 DeflateRect(rect);
87 Draw3DRect(hps,*rect,clrLight,clrLight);
88 }
89 else if (dwExStyle & WS_EX_STATICEDGE_W)
90 {
91 Draw3DRect(hps,*rect,clrWhite,clrDark);
92 }
93 else if (dwExStyle & WS_EX_WINDOWEDGE_W);
94 else if (dwStyle & WS_BORDER_W)
95 {
96 Draw3DRect(hps,*rect,clrBlack,clrBlack);
97 }
98
99 DeflateRect(rect);
100}
101//******************************************************************************
102//******************************************************************************
103BOOL CanDrawSizeBox(Win32BaseWindow *win32wnd)
104{
105 return (win32wnd->getStyle() & WS_SIZEBOX_W && WinQueryWindowULong(win32wnd->getOS2FrameWindowHandle(),QWL_STYLE) & FS_SIZEBORDER
106 && win32wnd->getVertScrollHandle() && WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle()
107 && win32wnd->getHorzScrollHandle() && WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT) == win32wnd->getOS2FrameWindowHandle());
108}
109//******************************************************************************
110//******************************************************************************
111VOID GetSizeBox(Win32BaseWindow *win32wnd,RECTL *rect)
112{
113 SWP swpHorz,swpVert;
114
115 WinQueryWindowPos(win32wnd->getVertScrollHandle(),&swpVert);
116 WinQueryWindowPos(win32wnd->getHorzScrollHandle(),&swpHorz);
117 rect->xLeft = swpVert.x;
118 rect->xRight = swpVert.x+swpVert.cx;
119 rect->yTop = swpHorz.y+swpHorz.cy;
120 rect->yBottom = swpHorz.y;
121}
122//******************************************************************************
123//******************************************************************************
124BOOL InSizeBox(Win32BaseWindow *win32wnd,POINTS *points)
125{
126 if (CanDrawSizeBox(win32wnd))
127 {
128 RECTL rect;
129 POINTL point;
130
131 point.x = points->x;
132 point.y = points->y;
133 GetSizeBox(win32wnd,&rect);
134 return (WinPtInRect(GetThreadHAB(),&rect,&point));
135 }
136
137 return FALSE;
138}
139//******************************************************************************
140//******************************************************************************
141VOID DrawSizeBox(HPS hps,RECTL rect)
142{
143 POINTL p1,p2;
144 LONG clrDark = CLR_DARKGRAY,clrWhite = CLR_WHITE;
145 INT x;
146
147 //CB: todo: switch to RGB mode and use win colors
148 WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
149 p1.x = rect.xRight-2;
150 p1.y = rect.yBottom;
151 p2.x = rect.xRight-1;
152 p2.y = rect.yBottom+1;
153 for (x = 0;x < 3;x++)
154 {
155 GpiSetColor(hps,clrDark);
156 GpiMove(hps,&p1);
157 GpiLine(hps,&p2);
158 p1.x--;
159 p2.y++;
160 GpiMove(hps,&p1);
161 GpiLine(hps,&p2);
162 GpiSetColor(hps,clrWhite);
163 p1.x--;
164 p2.y++;
165 GpiMove(hps,&p1);
166 GpiLine(hps,&p2);
167 p1.x -= 2;
168 p2.y += 2;
169 }
170}
171//******************************************************************************
172//******************************************************************************
173void DrawActivate(Win32BaseWindow *win32wnd, HWND hwnd)
174{
175 if (!win32wnd->isChild())
176 {
177 if (CanDrawSizeBox(win32wnd))
178 {
179 HPS hps;
180 RECTL rect;
181
182 GetSizeBox(win32wnd,&rect);
183 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
184 DrawSizeBox(hps,rect);
185 WinReleasePS(hps);
186
187 }
188 }
189 else
190 {
191 HPS hps;
192 RECTL rect;
193
194 WinQueryWindowRect(hwnd,&rect);
195 rect.xRight = rect.xRight-rect.xLeft;
196 rect.yTop = rect.yTop-rect.yBottom;
197 rect.xLeft = rect.yBottom = 0;
198 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
199 DrawFrame(hps,&rect,win32wnd);
200 WinReleasePS(hps);
201 }
202}
203//******************************************************************************
204//******************************************************************************
205void FrameTrackFrame(Win32BaseWindow *win32wnd,BOOL lefttop)
206{
207 INT flags = lefttop ? (TF_LEFT | TF_TOP):(TF_RIGHT | TF_BOTTOM);
208
209 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
210}
211//******************************************************************************
212// used by statusbar control
213//******************************************************************************
214VOID WINAPI TrackWin32Window(HWND hwnd,BOOL lefttop)
215{
216 Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
217 INT flags = lefttop ? (TF_LEFT | TF_TOP):(TF_RIGHT | TF_BOTTOM);
218
219 if (!win32wnd) return;
220
221 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
222}
223//******************************************************************************
224//Win32 frame message handler
225//******************************************************************************
226MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
227{
228 Win32BaseWindow *win32wnd;
229 PFNWP OldFrameProc;
230 MRESULT rc;
231
232 SetWin32TIB();
233
234 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
235
236 if(win32wnd == NULL || !win32wnd->getOldFrameProc())
237 {
238 dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
239 goto RunDefWndProc;
240 }
241
242 OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
243
244 switch(msg)
245 {
246 case WM_ADJUSTWINDOWPOS:
247 {
248 PSWP pswp = (PSWP)mp1;
249 SWP swpOld;
250 WINDOWPOS wp;
251 HWND hParent = NULLHANDLE, hwndAfter;
252
253 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));
254
255 //CB: show dialog in front of owner
256 if (win32wnd->IsModalDialogOwner())
257 {
258 pswp->fl |= SWP_ZORDER;
259 pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
260 if (pswp->fl & SWP_ACTIVATE)
261 {
262 pswp->fl &= ~SWP_ACTIVATE;
263 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
264 }
265 }
266
267 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
268 goto RunDefFrameProc;
269
270 if(!win32wnd->CanReceiveSizeMsgs()) {
271//SvL: Doing this breaks button.exe, header4(a).exe & style.exe
272// goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
273 break;
274 }
275
276 WinQueryWindowPos(hwnd, &swpOld);
277
278 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
279 if (win32wnd->isChild()) {
280 if(win32wnd->getParent()) {
281 hParent = win32wnd->getParent()->getOS2WindowHandle();
282 }
283 else goto RunDefFrameProc;
284 }
285 }
286 hwndAfter = pswp->hwndInsertBehind;
287 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
288
289 wp.hwnd = win32wnd->getWindowHandle();
290 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
291 {
292 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
293 if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
294 }
295
296 //CB: problems with profmine titlebar tracking
297 if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
298 {//app or default window handler changed wp
299 dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
300 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
301
302 OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
303 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
304 pswp->fl |= SWP_NOADJUST;
305 pswp->hwndInsertBehind = hwndAfter;
306 pswp->hwnd = hwnd;
307
308// goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
309 RestoreOS2TIB();
310 return (MRESULT)0xf;
311 }
312 goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
313 }
314
315 case WM_WINDOWPOSCHANGED:
316 {
317 PSWP pswp = (PSWP)mp1;
318 SWP swpOld = *(pswp + 1);
319 WINDOWPOS wp;
320 HWND hParent = NULLHANDLE;
321 LONG yDelta = pswp->cy - swpOld.cy;
322 LONG xDelta = pswp->cx - swpOld.cx;
323 LONG clientHeight;
324
325 dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
326
327 //Save height so WM_WINDOWPOSCHANGED handler in pmwindow.cpp
328 //(for client) doesn't overwrite the client rectangle (breaks ydelta calculation)
329 clientHeight = win32wnd->getWindowHeight();
330
331 RestoreOS2TIB();
332 rc = OldFrameProc(hwnd,msg,mp1,mp2);
333 SetWin32TIB();
334
335 if (win32wnd->getParent() && win32wnd->getParent()->InMovingChildren())
336 goto PosChangedEnd; //same Win32 pos, only OS/2 pos changed
337
338 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
339 goto PosChangedEnd;
340
341 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
342 if (win32wnd->isChild()) {
343 if(win32wnd->getParent()) {
344 hParent = win32wnd->getParent()->getOS2WindowHandle();
345 }
346 else goto PosChangedEnd; //parent has just been destroyed
347 }
348 }
349 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
350
351 //delta is difference between old and new client height
352 yDelta = swpOld.cy - clientHeight;
353
354 win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
355 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
356
357 wp.hwnd = win32wnd->getWindowHandle();
358 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
359 {
360 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
361 if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
362 }
363
364#if 0 //CB: PM does it now for us (-> WM_CALVALIDRECTS)
365 // if you remove this code, delete *MovingChildren in Win32BaseWindow class
366 if (yDelta != 0 || xDelta != 0)
367 {
368 HENUM henum = WinBeginEnumWindows(WinWindowFromID(hwnd,FID_CLIENT));
369 SWP swp[10];
370 int i = 0;
371 HWND hwnd;
372
373 win32wnd->setMovingChildren(TRUE);
374 while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
375 {
376 WinQueryWindowPos(hwnd, &(swp[i]));
377
378#ifdef DEBUG
379 Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
380 dprintf(("ENUMERATE %x delta %d (%d,%d) (%d,%d) %x", (window) ? window->getWindowHandle() : hwnd,
381 yDelta, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl));
382#endif
383
384 //if(swp[i].y != 0) //CB: y value of 0 is valid!
385 {
386 //child window at offset <> 0 from client area -> offset now changes
387 swp[i].y += yDelta;
388 swp[i].fl = SWP_MOVE | SWP_NOADJUST;
389 }
390 //else child window with the same start coordinates as the client area
391 //The app should resize it.
392
393 if (i == 9)
394 {
395 WinSetMultWindowPos(GetThreadHAB(), swp, 10);
396 i = 0;
397 }
398 else
399 {
400 i++;
401 }
402 }
403
404 WinEndEnumWindows(henum);
405
406 if (i)
407 WinSetMultWindowPos(GetThreadHAB(), swp, i);
408 win32wnd->setMovingChildren(FALSE);
409 }
410 if (yDelta != 0)
411 {
412 POINT pt;
413 if(GetCaretPos (&pt) == TRUE)
414 {
415 pt.y -= yDelta;
416 SetCaretPos (pt.x, pt.y);
417 }
418 }
419#endif
420 if(!win32wnd->CanReceiveSizeMsgs())
421 goto PosChangedEnd;
422
423 win32wnd->MsgPosChanged((LPARAM)&wp);
424
425PosChangedEnd:
426 RestoreOS2TIB();
427 return rc;
428 }
429
430 case WM_CALCVALIDRECTS:
431 {
432 PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
433 UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
434
435 //CB: only used if CS_SIZEDRAW isn't set
436 // PM moves children -> fast, no flickering (if redraw flags not set)
437 if (win32wnd->getWindowClass())
438 {
439 DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
440
441 if (dwStyle & CS_HREDRAW_W && newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft)
442 res |= CVR_REDRAW;
443 else if (dwStyle & CS_VREDRAW_W && newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom)
444 res |= CVR_REDRAW;
445 } else res |= CVR_REDRAW;
446
447 //CB: PM updates window frame (and unfortunately all other frame controls)
448 RestoreOS2TIB();
449 OldFrameProc(hwnd,msg,mp1,mp2);
450 SetWin32TIB();
451
452 RestoreOS2TIB();
453 return (MRESULT)res;
454 }
455
456 case WM_ACTIVATE:
457 {
458 HWND hwndTitle;
459 USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
460
461 //CB: emulate WM_ACTIVATE -> no flickering
462 hwndTitle = WinWindowFromID(hwnd,FID_TITLEBAR);
463 if (hwndTitle) WinSendMsg(hwndTitle,TBM_SETHILITE,mp1,MPVOID);
464
465 WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
466 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
467
468 //CB: show owner behind the dialog
469 if (win32wnd->IsModalDialog())
470 {
471 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
472
473 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
474 }
475
476 RestoreOS2TIB();
477 return 0;
478 }
479
480 case WM_DESTROY:
481 #ifdef PMFRAMELOG
482 dprintf(("PMFRAME: WM_DESTROY"));
483 #endif
484 WinSubclassWindow(hwnd,OldFrameProc);
485 win32wnd->setOldFrameProc(NULL);
486 goto RunDefFrameProc;
487
488 case WM_MOUSEMOVE:
489 if (InSizeBox(win32wnd,(POINTS*)&mp1))
490 {
491 WinSetPointer(HWND_DESKTOP,WinQuerySysPointer(HWND_DESKTOP,SPTR_SIZENWSE,FALSE));
492 RestoreOS2TIB();
493 return (MRESULT)TRUE;
494 }
495 else if (win32wnd->isChild()) goto RunDefWndProc;
496 else goto RunDefFrameProc;
497
498 case WM_BUTTON1DOWN:
499 #ifdef PMFRAMELOG
500 dprintf(("PMFRAME: WM_BUTTON1DOWN"));
501 #endif
502
503 if (InSizeBox(win32wnd,(POINTS*)&mp1))
504 {
505 WinSetActiveWindow(HWND_DESKTOP,hwnd);
506 WinSendMsg(hwnd,WM_TRACKFRAME,(MPARAM)(TF_RIGHT | TF_BOTTOM),(MPARAM)0);
507 RestoreOS2TIB();
508 return (MRESULT)TRUE;
509 }
510 else if (win32wnd->isChild()) goto RunDefWndProc;
511 else goto RunDefFrameProc;
512
513 case WM_BUTTON2DOWN:
514 case WM_BUTTON3DOWN:
515 #ifdef PMFRAMELOG
516 dprintf(("PMFRAME: WM_BUTTON2/3DOWN"));
517 #endif
518 if (win32wnd->isChild()) goto RunDefWndProc;
519 else goto RunDefFrameProc;
520
521 case WM_PAINT:
522 #ifdef PMFRAMELOG
523 dprintf(("PMFRAME: WM_PAINT"));
524 #endif
525 if (!win32wnd->isChild())
526 {
527 if (CanDrawSizeBox(win32wnd))
528 {
529 MRESULT res;
530 HPS hps;
531 RECTL rect;
532
533 RestoreOS2TIB();
534 res = OldFrameProc(hwnd,msg,mp1,mp2);
535 SetWin32TIB();
536
537 GetSizeBox(win32wnd,&rect);
538 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
539 DrawSizeBox(hps,rect);
540 WinReleasePS(hps);
541
542 RestoreOS2TIB();
543 return res;
544 }
545 else goto RunDefFrameProc;
546 }
547 else
548 {
549 RECTL rect;
550 HPS hps;
551
552 RestoreOS2TIB();
553 OldFrameProc(hwnd,msg,mp1,mp2);
554 SetWin32TIB();
555
556 WinQueryWindowRect(hwnd,&rect);
557 rect.xRight = rect.xRight-rect.xLeft;
558 rect.yTop = rect.yTop-rect.yBottom;
559 rect.xLeft = rect.yBottom = 0;
560 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
561 DrawFrame(hps,&rect,win32wnd);
562 WinReleasePS(hps);
563
564 RestoreOS2TIB();
565 return (MRESULT)0;
566 }
567
568 default:
569 RestoreOS2TIB();
570 return OldFrameProc(hwnd,msg,mp1,mp2);
571 }
572
573 RestoreOS2TIB();
574 return (MRESULT)FALSE;
575
576RunDefFrameProc:
577 RestoreOS2TIB();
578 return OldFrameProc(hwnd,msg,mp1,mp2);
579
580RunDefWndProc:
581 RestoreOS2TIB();
582 return WinDefWindowProc(hwnd,msg,mp1,mp2);
583}
584
585PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
586{
587 return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
588}
589
590VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
591{
592 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
593}
594
595VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
596{
597 POINTL point;
598
599 if (!resize)
600 {
601 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
602
603 return;
604 }
605
606 FrameGetBorderSize(win32wnd,&point);
607 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
608 if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight())
609 {
610 INT xDiff = win32wnd->getBorderWidth()-point.x;
611 INT yDiff = win32wnd->getBorderHeight()-point.y;
612 SWP swp;
613
614 WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
615 swp.x += xDiff;
616 swp.y += yDiff;
617 swp.cx -= 2*xDiff;
618 swp.cy -= 2*yDiff;
619 WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
620 }
621}
622
623UINT FrameGetDefSizeBorderSize(VOID)
624{
625 return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
626}
627
628BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
629{
630 HWND hwndHScroll = 0,hwndVScroll = 0;
631 ULONG updateFlags = 0;
632
633 if (createHorz)
634 {
635 hwndHScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_HORZ,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_HORZSCROLL,NULL,NULL);
636 if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
637 else return FALSE;
638 updateFlags = FCF_HORZSCROLL;
639 }
640
641 if (createVert)
642 {
643 hwndVScroll = WinCreateWindow(win32wnd->getOS2FrameWindowHandle(),WC_SCROLLBAR,"",WS_VISIBLE | WS_PARENTCLIP | WS_SYNCPAINT | SBS_VERT,0,0,0,0,win32wnd->getOS2FrameWindowHandle(),HWND_TOP,FID_VERTSCROLL,NULL,NULL);
644 if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
645 {
646 if (hwndHScroll) WinDestroyWindow(hwndHScroll);
647
648 return FALSE;
649 }
650 updateFlags |= FCF_VERTSCROLL;
651 }
652
653 win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
654
655 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
656 if (flags) *flags = updateFlags;
657
658 return TRUE;
659}
660
661VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
662{
663 if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
664 if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
665}
666
667BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
668{
669 HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
670 ULONG updateFlags = 0;
671
672 if (changeHorz)
673 {
674 HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
675
676 if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
677 {
678 WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
679 updateFlags |= FCF_HORZSCROLL;
680 }
681 }
682
683 if (changeVert)
684 {
685 HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
686
687 if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
688 {
689 WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
690 updateFlags |= FCF_VERTSCROLL;
691 }
692 }
693
694 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
695 if (flags) *flags = updateFlags;
696
697 return TRUE;
698}
699
700VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
701{
702 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
703}
704
Note: See TracBrowser for help on using the repository browser.