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

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

ported all USER32 bitmaps, several bug fixes

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