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

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

System menu commands now work

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