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

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

single frame works now

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