source: trunk/src/user32/new/pmframe.cpp@ 2291

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

first few changes

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