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

Last change on this file since 2204 was 2204, checked in by cbratschi, 26 years ago

non-client fixes, DefWndProc enhancements, several other bugs fixed

File size: 20.8 KB
Line 
1/* $Id: pmframe.cpp,v 1.30 1999-12-26 17:30:16 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 "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,DWORD flags)
206{
207 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_TRACKFRAME,(MPARAM)flags,(MPARAM)0);
208}
209//******************************************************************************
210//Win32 frame message handler
211//******************************************************************************
212MRESULT EXPENTRY Win32FrameProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
213{
214 Win32BaseWindow *win32wnd;
215 PFNWP OldFrameProc;
216 MRESULT rc;
217
218 SetWin32TIB();
219
220 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
221
222 if(win32wnd == NULL || !win32wnd->getOldFrameProc())
223 {
224 dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
225 goto RunDefWndProc;
226 }
227
228 OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
229
230 switch(msg)
231 {
232 case WM_ADJUSTWINDOWPOS:
233 {
234 PSWP pswp = (PSWP)mp1;
235 SWP swpOld;
236 WINDOWPOS wp;
237 HWND hParent = NULLHANDLE, hwndAfter;
238
239 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));
240
241 //CB: show dialog in front of owner
242 if (win32wnd->IsModalDialogOwner())
243 {
244 pswp->fl |= SWP_ZORDER;
245 pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
246 if (pswp->fl & SWP_ACTIVATE)
247 {
248 pswp->fl &= ~SWP_ACTIVATE;
249 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
250 }
251 }
252
253 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
254 goto RunDefFrameProc;
255
256 if(!win32wnd->CanReceiveSizeMsgs()) {
257//SvL: Doing this breaks button.exe, header4(a).exe & style.exe
258// goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
259 break;
260 }
261
262 WinQueryWindowPos(hwnd, &swpOld);
263
264 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
265 if (win32wnd->isChild()) {
266 if(win32wnd->getParent()) {
267 hParent = win32wnd->getParent()->getOS2WindowHandle();
268 }
269 else goto RunDefFrameProc;
270 }
271 }
272 hwndAfter = pswp->hwndInsertBehind;
273 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
274
275 wp.hwnd = win32wnd->getWindowHandle();
276 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
277 {
278 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
279 if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
280 }
281
282 //CB: problems with profmine titlebar tracking
283 if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
284 {//app or default window handler changed wp
285 dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
286 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
287
288 OSLibMapWINDOWPOStoSWPFrame(&wp, pswp, &swpOld, hParent, hwnd);
289 dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
290 pswp->fl |= SWP_NOADJUST;
291 pswp->hwndInsertBehind = hwndAfter;
292 pswp->hwnd = hwnd;
293
294// goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
295 RestoreOS2TIB();
296 return (MRESULT)0xf;
297 }
298 goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
299 }
300
301 case WM_WINDOWPOSCHANGED:
302 {
303 PSWP pswp = (PSWP)mp1;
304 SWP swpOld = *(pswp + 1);
305 WINDOWPOS wp;
306 HWND hParent = NULLHANDLE;
307
308 dprintf(("PMFRAME: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
309
310 RestoreOS2TIB();
311 rc = OldFrameProc(hwnd,msg,mp1,mp2);
312 SetWin32TIB();
313
314 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
315 goto PosChangedEnd;
316
317 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
318 if (win32wnd->isChild()) {
319 if(win32wnd->getParent()) {
320 hParent = win32wnd->getParent()->getOS2WindowHandle();
321 }
322 else goto PosChangedEnd; //parent has just been destroyed
323 }
324 }
325 OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
326
327 win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
328 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
329
330 if(win32wnd->CanReceiveSizeMsgs())
331 win32wnd->MsgPosChanged((LPARAM)&wp);
332
333PosChangedEnd:
334 RestoreOS2TIB();
335 return rc;
336 }
337
338 case WM_CALCVALIDRECTS:
339 {
340 PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
341 UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
342
343 //CB: only used if CS_SIZEDRAW isn't set
344 // PM moves children -> fast, no flickering (if redraw flags not set)
345 if (win32wnd->getWindowClass())
346 {
347 DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
348
349 if (dwStyle & CS_HREDRAW_W && newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft)
350 res |= CVR_REDRAW;
351 else if (dwStyle & CS_VREDRAW_W && newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom)
352 res |= CVR_REDRAW;
353 } else res |= CVR_REDRAW;
354
355 //CB: PM updates window frame (and unfortunately all other frame controls)
356 RestoreOS2TIB();
357 OldFrameProc(hwnd,msg,mp1,mp2);
358 SetWin32TIB();
359
360 RestoreOS2TIB();
361 return (MRESULT)res;
362 }
363
364 case WM_ACTIVATE:
365 {
366 HWND hwndTitle;
367 USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
368
369 //CB: emulate WM_ACTIVATE -> no flickering
370 hwndTitle = WinWindowFromID(hwnd,FID_TITLEBAR);
371 if (hwndTitle) WinSendMsg(hwndTitle,TBM_SETHILITE,mp1,MPVOID);
372
373 WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
374 WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
375
376 //CB: show owner behind the dialog
377 if (win32wnd->IsModalDialog())
378 {
379 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
380
381 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
382 }
383
384 RestoreOS2TIB();
385 return 0;
386 }
387
388 case WM_DESTROY:
389 #ifdef PMFRAMELOG
390 dprintf(("PMFRAME: WM_DESTROY"));
391 #endif
392 WinSubclassWindow(hwnd,OldFrameProc);
393 win32wnd->setOldFrameProc(NULL);
394 goto RunDefFrameProc;
395
396 case WM_MOUSEMOVE:
397 if (InSizeBox(win32wnd,(POINTS*)&mp1))
398 {
399 WinSetPointer(HWND_DESKTOP,WinQuerySysPointer(HWND_DESKTOP,SPTR_SIZENWSE,FALSE));
400 RestoreOS2TIB();
401 return (MRESULT)TRUE;
402 }
403 else if (win32wnd->isChild()) goto RunDefWndProc;
404 else goto RunDefFrameProc;
405
406 case WM_BUTTON1DOWN:
407 #ifdef PMFRAMELOG
408 dprintf(("PMFRAME: WM_BUTTON1DOWN"));
409 #endif
410
411 if (InSizeBox(win32wnd,(POINTS*)&mp1))
412 {
413 WinSetActiveWindow(HWND_DESKTOP,hwnd);
414 WinSendMsg(hwnd,WM_TRACKFRAME,(MPARAM)(TF_RIGHT | TF_BOTTOM),(MPARAM)0);
415 RestoreOS2TIB();
416 return (MRESULT)TRUE;
417 }
418 else if (win32wnd->isChild()) goto RunDefWndProc;
419 else goto RunDefFrameProc;
420
421 case WM_BUTTON2DOWN:
422 case WM_BUTTON3DOWN:
423 #ifdef PMFRAMELOG
424 dprintf(("PMFRAME: WM_BUTTON2/3DOWN"));
425 #endif
426 if (win32wnd->isChild()) goto RunDefWndProc;
427 else goto RunDefFrameProc;
428
429 case WM_PAINT:
430 #ifdef PMFRAMELOG
431 dprintf(("PMFRAME: WM_PAINT"));
432 #endif
433 if (!win32wnd->isChild())
434 {
435 if (CanDrawSizeBox(win32wnd))
436 {
437 MRESULT res;
438 HPS hps;
439 RECTL rect;
440
441 RestoreOS2TIB();
442 res = OldFrameProc(hwnd,msg,mp1,mp2);
443 SetWin32TIB();
444
445 GetSizeBox(win32wnd,&rect);
446 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
447 DrawSizeBox(hps,rect);
448 WinReleasePS(hps);
449
450 RestoreOS2TIB();
451 return res;
452 }
453 else goto RunDefFrameProc;
454 }
455 else
456 {
457 RECTL rect;
458 HPS hps;
459
460 RestoreOS2TIB();
461 OldFrameProc(hwnd,msg,mp1,mp2);
462 SetWin32TIB();
463
464 WinQueryWindowRect(hwnd,&rect);
465 rect.xRight = rect.xRight-rect.xLeft;
466 rect.yTop = rect.yTop-rect.yBottom;
467 rect.xLeft = rect.yBottom = 0;
468 hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN | PSF_CLIPSIBLINGS);
469 DrawFrame(hps,&rect,win32wnd);
470 WinReleasePS(hps);
471
472 RestoreOS2TIB();
473 return (MRESULT)0;
474 }
475
476 default:
477 RestoreOS2TIB();
478 return OldFrameProc(hwnd,msg,mp1,mp2);
479 }
480
481 RestoreOS2TIB();
482 return (MRESULT)FALSE;
483
484RunDefFrameProc:
485 RestoreOS2TIB();
486 return OldFrameProc(hwnd,msg,mp1,mp2);
487
488RunDefWndProc:
489 RestoreOS2TIB();
490 return WinDefWindowProc(hwnd,msg,mp1,mp2);
491}
492
493PVOID FrameSubclassFrameWindow(Win32BaseWindow *win32wnd)
494{
495 return WinSubclassWindow(win32wnd->getOS2FrameWindowHandle(),PFNWP(Win32FrameProc));
496}
497
498VOID FrameGetBorderSize(Win32BaseWindow *win32wnd,PWPOINT pSize)
499{
500 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_QUERYBORDERSIZE,(MPARAM)pSize,(MPARAM)0);
501}
502
503VOID FrameSetBorderSize(Win32BaseWindow *win32wnd,BOOL resize)
504{
505 POINTL point;
506
507 if (!resize)
508 {
509 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
510
511 return;
512 }
513
514 FrameGetBorderSize(win32wnd,&point);
515 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_SETBORDERSIZE,(MPARAM)win32wnd->getBorderWidth(),(MPARAM)win32wnd->getBorderHeight());
516 if (point.x != win32wnd->getBorderWidth() || point.y != win32wnd->getBorderHeight())
517 {
518 INT xDiff = win32wnd->getBorderWidth()-point.x;
519 INT yDiff = win32wnd->getBorderHeight()-point.y;
520 SWP swp;
521
522 WinQueryWindowPos(win32wnd->getOS2FrameWindowHandle(),&swp);
523 swp.x += xDiff;
524 swp.y += yDiff;
525 swp.cx -= 2*xDiff;
526 swp.cy -= 2*yDiff;
527 WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),0,swp.x,swp.y,swp.cx,swp.cy,SWP_MOVE | SWP_SIZE);
528 }
529}
530
531UINT FrameGetDefSizeBorderSize(VOID)
532{
533 return WinQuerySysValue(HWND_DESKTOP,SV_CXSIZEBORDER);
534}
535
536BOOL FrameCreateScrollBars(Win32BaseWindow *win32wnd,BOOL createHorz,BOOL createVert,BOOL updateFrame,DWORD *flags)
537{
538 HWND hwndHScroll = 0,hwndVScroll = 0;
539 ULONG updateFlags = 0;
540
541 if (createHorz)
542 {
543 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);
544 if (hwndHScroll) win32wnd->setHorzScrollHandle(hwndHScroll);
545 else return FALSE;
546 updateFlags = FCF_HORZSCROLL;
547 }
548
549 if (createVert)
550 {
551 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);
552 if (hwndVScroll) win32wnd->setVertScrollHandle(hwndVScroll); else
553 {
554 if (hwndHScroll) WinDestroyWindow(hwndHScroll);
555
556 return FALSE;
557 }
558 updateFlags |= FCF_VERTSCROLL;
559 }
560
561 win32wnd->subclassScrollBars(hwndHScroll,hwndVScroll);
562
563 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)0,(MPARAM)0);
564 if (flags) *flags = updateFlags;
565
566 return TRUE;
567}
568
569VOID FrameGetScrollBarHandles(Win32BaseWindow *win32wnd,BOOL getHorz,BOOL getVert)
570{
571 if (getHorz) win32wnd->setHorzScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_HORZSCROLL));
572 if (getVert) win32wnd->setVertScrollHandle(WinWindowFromID(win32wnd->getOS2FrameWindowHandle(),FID_VERTSCROLL));
573}
574
575BOOL FrameShowScrollBars(Win32BaseWindow *win32wnd,BOOL changeHorz,BOOL changeVert,BOOL fShow,BOOL updateFrame,DWORD *flags)
576{
577 HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP);
578 ULONG updateFlags = 0;
579
580 if (changeHorz)
581 {
582 HWND hwndCurPar = WinQueryWindow(win32wnd->getHorzScrollHandle(),QW_PARENT);
583
584 if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
585 {
586 WinSetParent(win32wnd->getHorzScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
587 updateFlags |= FCF_HORZSCROLL;
588 }
589 }
590
591 if (changeVert)
592 {
593 HWND hwndCurPar = WinQueryWindow(win32wnd->getVertScrollHandle(),QW_PARENT);
594
595 if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj))
596 {
597 WinSetParent(win32wnd->getVertScrollHandle(),fShow ? win32wnd->getOS2FrameWindowHandle():HWND_OBJECT,FALSE);
598 updateFlags |= FCF_VERTSCROLL;
599 }
600 }
601
602 if (updateFrame && updateFlags) WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)updateFlags,(MPARAM)0);
603 if (flags) *flags = updateFlags;
604
605 return TRUE;
606}
607
608VOID FrameUpdateFrame(Win32BaseWindow *win32wnd,DWORD flags)
609{
610 WinSendMsg(win32wnd->getOS2FrameWindowHandle(),WM_UPDATEFRAME,(MPARAM)flags,(MPARAM)0);
611}
612
613DWORD FrameHitTest(Win32BaseWindow *win32wnd,INT x,INT y)
614{
615 POINTL point;
616 HWND hwnd = win32wnd->getOS2FrameWindowHandle(),child;
617
618 if (hwnd == win32wnd->getOS2WindowHandle()) return HTCLIENT_W;
619 if (win32wnd->getOS2WindowHandle() == WinQueryCapture(HWND_DESKTOP)) return HTCLIENT_W;
620 point.x = x;
621 point.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-y-1;
622 WinMapWindowPoints(HWND_DESKTOP,hwnd,&point,1);
623 child = WinWindowFromPoint(hwnd,&point,FALSE);
624
625 if (child == 0) return HTERROR_W;
626 if (child == win32wnd->getOS2FrameWindowHandle())
627 {
628 RECTL client,frame;
629
630 if (CanDrawSizeBox(win32wnd))
631 {
632 RECTL rect;
633
634 GetSizeBox(win32wnd,&rect);
635 if (WinPtInRect(GetThreadHAB(),&rect,&point)) return HTGROWBOX_W;
636 }
637 //somewhere in the border
638 INT w = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
639 INT h = WinQuerySysValue(HWND_DESKTOP,SV_CXMINMAXBUTTON);
640 WinQueryWindowRect(hwnd,&frame);
641
642 if (point.y < h)
643 {
644 if (point.x < w) return HTBOTTOMLEFT_W;
645 if (point.x > frame.xRight-1-w) return HTBOTTOMRIGHT_W;
646 return HTBOTTOM_W;
647 }
648 if (point.y > frame.yTop-1-h)
649 {
650 if (point.x < w) return HTTOPLEFT_W;
651 if (point.x > frame.xRight-1-w) return HTTOPRIGHT_W;
652 return HTTOP_W;
653 }
654 return HTBORDER_W;
655 } else
656 {
657 if (child == WinWindowFromID(hwnd,FID_CLIENT)) return HTCLIENT_W;
658 if (child == WinWindowFromID(hwnd,FID_VERTSCROLL)) return HTVSCROLL_W;
659 if (child == WinWindowFromID(hwnd,FID_HORZSCROLL)) return HTHSCROLL_W;
660 if (child == WinWindowFromID(hwnd,FID_SYSMENU)) return HTSYSMENU_W;
661 if (child == WinWindowFromID(hwnd,FID_TITLEBAR)) return HTCAPTION_W;
662 if (child == WinWindowFromID(hwnd,FID_MENU)) return HTMENU_W;
663 if (child == WinWindowFromID(hwnd,FID_MINMAX))
664 {
665 //CB: close, reduce or zoom
666 return HTZOOM_W;
667 }
668
669 return HTERROR_W;
670 }
671}
Note: See TracBrowser for help on using the repository browser.