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

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

OSLibGetMsg bugfix + WM_QUIT translation fix

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