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

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

* empty log message *

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