source: trunk/src/user32/new/win32wbasenonclient.cpp@ 2452

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

child window system menu + titlebar tracking bugfixes

File size: 39.6 KB
Line 
1/* $Id: win32wbasenonclient.cpp,v 1.12 2000-01-15 17:27:20 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2 (non-client methods)
4 *
5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
6 *
7 * Based on Wine code (windows\nonclient.c)
8 *
9 * Copyright 1994 Alexandre Julliard
10 *
11 * TODO: Not thread/process safe
12 *
13 * Project Odin Software License can be found in LICENSE.TXT
14 *
15 */
16#include <os2win.h>
17#include <win.h>
18#include <stdlib.h>
19#include <string.h>
20#include <stdarg.h>
21#include <assert.h>
22#include <misc.h>
23#include <heapstring.h>
24#include <win32wbase.h>
25#include <winres.h>
26#include "wndmsg.h"
27#include "pmframe.h"
28#include "oslibwin.h"
29#include "oslibmsg.h"
30#include "oslibutil.h"
31#include "oslibgdi.h"
32#include "oslibres.h"
33#include "oslibdos.h"
34#include "syscolor.h"
35#include "win32wndhandle.h"
36#include "dc.h"
37#include "win32wdesktop.h"
38#include "controls.h"
39#include <menu.h>
40
41#define SC_ABOUTODIN (SC_SCREENSAVE+1)
42#define SC_PUTMARK (SC_SCREENSAVE+2)
43
44/* bits in the dwKeyData */
45#define KEYDATA_ALT 0x2000
46#define KEYDATA_PREVSTATE 0x4000
47
48static HBITMAP hbitmapClose = 0;
49static HBITMAP hbitmapCloseD = 0;
50static HBITMAP hbitmapMinimize = 0;
51static HBITMAP hbitmapMinimizeD = 0;
52static HBITMAP hbitmapMaximize = 0;
53static HBITMAP hbitmapMaximizeD = 0;
54static HBITMAP hbitmapRestore = 0;
55static HBITMAP hbitmapRestoreD = 0;
56
57BYTE lpGrayMask[] = { 0xAA, 0xA0,
58 0x55, 0x50,
59 0xAA, 0xA0,
60 0x55, 0x50,
61 0xAA, 0xA0,
62 0x55, 0x50,
63 0xAA, 0xA0,
64 0x55, 0x50,
65 0xAA, 0xA0,
66 0x55, 0x50};
67
68static INT (* WINAPI ShellAboutA)(HWND,LPCSTR,LPCSTR,HICON) = 0;
69
70//******************************************************************************
71//******************************************************************************
72LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
73{
74 WORD wStateChange;
75
76 //CB: only caption is changed on activation
77 if (!(dwStyle & WS_CAPTION)) return TRUE;
78
79 if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
80 else wStateChange = flags & WIN_NCACTIVATED;
81
82 if( wStateChange )
83 {
84 if (wParam) flags |= WIN_NCACTIVATED;
85 else flags &= ~WIN_NCACTIVATED;
86
87 if(!(dwStyle & WS_MINIMIZE))
88 DoNCPaint((HRGN)1,FALSE);
89 }
90
91 return TRUE;
92}
93//******************************************************************************
94//******************************************************************************
95VOID Win32BaseWindow::TrackMinMaxBox(WORD wParam)
96{
97 MSG msg;
98 HDC hdc;
99 BOOL pressed = TRUE;
100 UINT state;
101
102 if (wParam == HTMINBUTTON)
103 {
104 /* If the style is not present, do nothing */
105 if (!(dwStyle & WS_MINIMIZEBOX))
106 return;
107 /* Check if the sysmenu item for minimize is there */
108 state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
109 } else
110 {
111 /* If the style is not present, do nothing */
112 if (!(dwStyle & WS_MAXIMIZEBOX))
113 return;
114 /* Check if the sysmenu item for maximize is there */
115 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
116 }
117 SetCapture(Win32Hwnd);
118 hdc = GetWindowDC(Win32Hwnd);
119 if (wParam == HTMINBUTTON)
120 DrawMinButton(hdc,NULL,TRUE,FALSE);
121 else
122 DrawMaxButton(hdc,NULL,TRUE,FALSE);
123 do
124 {
125 BOOL oldstate = pressed;
126
127 GetMessageA(&msg,Win32Hwnd,0,0);
128 pressed = (HandleNCHitTest(msg.pt) == wParam);
129 if (pressed != oldstate)
130 {
131 if (wParam == HTMINBUTTON)
132 DrawMinButton(hdc,NULL,pressed,FALSE);
133 else
134 DrawMaxButton(hdc,NULL,pressed,FALSE);
135 }
136 } while (msg.message != WM_LBUTTONUP);
137 if (wParam == HTMINBUTTON)
138 DrawMinButton(hdc,NULL,FALSE,FALSE);
139 else
140 DrawMaxButton(hdc,NULL,FALSE,FALSE);
141 ReleaseCapture();
142 ReleaseDC(Win32Hwnd,hdc);
143 /* If the item minimize or maximize of the sysmenu are not there */
144 /* or if the style is not present, do nothing */
145 if ((!pressed) || (state == 0xFFFFFFFF))
146 return;
147 if (wParam == HTMINBUTTON)
148 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
149 else
150 SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
151}
152//******************************************************************************
153//******************************************************************************
154VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
155{
156 MSG msg;
157 HDC hdc;
158 BOOL pressed = TRUE;
159 UINT state;
160
161 if (hSysMenu == 0)
162 return;
163 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
164 /* If the item close of the sysmenu is disabled or not there do nothing */
165 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
166 return;
167 hdc = GetWindowDC(Win32Hwnd);
168 SetCapture(Win32Hwnd);
169 DrawCloseButton(hdc,NULL,TRUE,FALSE);
170 do
171 {
172 BOOL oldstate = pressed;
173
174 GetMessageA(&msg,Win32Hwnd,0,0);
175 pressed = (HandleNCHitTest(msg.pt) == wParam);
176 if (pressed != oldstate)
177 DrawCloseButton(hdc,NULL,pressed,FALSE);
178 } while (msg.message != WM_LBUTTONUP);
179 DrawCloseButton(hdc,NULL,FALSE,FALSE);
180 ReleaseCapture();
181 ReleaseDC(Win32Hwnd,hdc);
182 if (!pressed) return;
183 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
184}
185//******************************************************************************
186//******************************************************************************
187VOID Win32BaseWindow::TrackScrollBar(WPARAM wParam,POINT pt)
188{
189 INT scrollbar;
190 MSG msg;
191
192 if ((wParam & 0xfff0) == SC_HSCROLL)
193 {
194 if ((wParam & 0x0f) != HTHSCROLL) return;
195 scrollbar = SB_HORZ;
196 } else /* SC_VSCROLL */
197 {
198 if ((wParam & 0x0f) != HTVSCROLL) return;
199 scrollbar = SB_VERT;
200 }
201
202 pt.x -= rectWindow.left;
203 pt.y -= rectWindow.top;
204 SCROLL_HandleScrollEvent(Win32Hwnd,0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
205 if (GetCapture() != Win32Hwnd) return;
206 do
207 {
208 GetMessageA(&msg, 0, 0, 0);
209 if(msg.hwnd == getWindowHandle())
210 {
211 switch(msg.message)
212 {
213 case WM_LBUTTONUP:
214 case WM_MOUSEMOVE:
215 pt.x = msg.pt.x-rectWindow.left;
216 pt.y = msg.pt.y-rectWindow.top;
217 msg.lParam = MAKELONG(pt.x,pt.y);
218
219 case WM_SYSTIMER:
220 SCROLL_HandleScrollEvent(Win32Hwnd,msg.wParam,msg.lParam,scrollbar,msg.message);
221 break;
222
223 default:
224 TranslateMessage(&msg);
225 DispatchMessageA(&msg);
226 break;
227 }
228 }
229 else {
230 TranslateMessage(&msg);
231 DispatchMessageA(&msg);
232 }
233 if (!IsWindow())
234 {
235 ReleaseCapture();
236 break;
237 }
238 } while (msg.message != WM_LBUTTONUP);
239}
240//******************************************************************************
241//******************************************************************************
242LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
243{
244 switch(wParam) /* Hit test */
245 {
246 case HTCAPTION:
247 {
248 Win32BaseWindow *topparent = GetTopParent();
249
250 if (GetActiveWindow() != topparent->getWindowHandle())
251 topparent->SetActiveWindow();
252
253 if (GetActiveWindow() == topparent->getWindowHandle())
254 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
255 break;
256 }
257
258 case HTSYSMENU:
259 if(dwStyle & WS_SYSMENU )
260 {
261 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
262 }
263 break;
264
265 case HTMENU:
266 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU,lParam);
267 break;
268
269 case HTHSCROLL:
270 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
271 break;
272
273 case HTVSCROLL:
274 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
275 break;
276
277 case HTMINBUTTON:
278 case HTMAXBUTTON:
279 TrackMinMaxBox(wParam);
280 break;
281
282 case HTCLOSE:
283 TrackCloseButton(wParam);
284 break;
285
286 case HTLEFT:
287 case HTRIGHT:
288 case HTTOP:
289 case HTTOPLEFT:
290 case HTTOPRIGHT:
291 case HTBOTTOM:
292 case HTBOTTOMLEFT:
293 case HTBOTTOMRIGHT:
294 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
295 SendInternalMessageA(WM_SYSCOMMAND,SC_SIZE+wParam-2,lParam);
296 break;
297 case HTBORDER:
298 break;
299 }
300
301 return 0;
302}
303//******************************************************************************
304//******************************************************************************
305BOOL Win32BaseWindow::WindowNeedsWMBorder()
306{
307 if (!(dwStyle & WS_CHILD) &&
308 //Options.managed && //CB: to check
309 !(dwExStyle & WS_EX_TOOLWINDOW) &&
310 ( ((dwStyle & WS_CAPTION) == WS_CAPTION) ||
311 (dwStyle & WS_THICKFRAME)))
312 return TRUE;
313 if (dwExStyle & WS_EX_TRAYWINDOW)
314 return TRUE;
315 return FALSE;
316}
317//******************************************************************************
318//******************************************************************************
319VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
320{
321 if(dwStyle & WS_ICONIC) return;
322
323 /* Decide if the window will be managed (see CreateWindowEx) */
324 //if (!WindowNeedsWMBorder()) //CB: check Options.managed
325 {
326 if (HAS_THICKFRAME(dwStyle,dwExStyle ))
327 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
328 else
329 if (HAS_DLGFRAME( dwStyle, dwExStyle ))
330 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
331 else
332 if (HAS_THINFRAME( dwStyle ))
333 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
334
335 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
336 {
337 if (dwExStyle & WS_EX_TOOLWINDOW)
338 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
339 else
340 rect->top -= GetSystemMetrics(SM_CYCAPTION);
341 }
342 }
343
344 if (menu)
345 rect->top -= GetSystemMetrics(SM_CYMENU);
346}
347//******************************************************************************
348//******************************************************************************
349VOID Win32BaseWindow::AdjustRectInner(LPRECT rect)
350{
351 if(dwStyle & WS_ICONIC) return;
352
353 if (dwExStyle & WS_EX_CLIENTEDGE)
354 InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
355
356 if (dwExStyle & WS_EX_STATICEDGE)
357 InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
358
359 if (dwStyle & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
360 if (dwStyle & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
361}
362//******************************************************************************
363//******************************************************************************
364LONG Win32BaseWindow::HandleNCCalcSize(BOOL calcValidRects,RECT *winRect)
365{
366 RECT tmpRect = { 0, 0, 0, 0 };
367 LONG result = 0;
368 UINT style;
369
370 if (!calcValidRects) return 0;
371
372 style = (UINT) GetClassLongA(Win32Hwnd,GCL_STYLE);
373
374 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
375 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
376
377 if(!(dwStyle & WS_MINIMIZE))
378 {
379 AdjustRectOuter(&tmpRect,FALSE);
380
381 winRect->left -= tmpRect.left;
382 winRect->top -= tmpRect.top;
383 winRect->right -= tmpRect.right;
384 winRect->bottom -= tmpRect.bottom;
385
386 if (HAS_MENU())
387 {
388 winRect->top +=
389 MENU_GetMenuBarHeight(Win32Hwnd,
390 winRect->right - winRect->left,
391 -tmpRect.left, -tmpRect.top ) + 1;
392 }
393
394 SetRect (&tmpRect, 0, 0, 0, 0);
395 AdjustRectInner(&tmpRect);
396 winRect->left -= tmpRect.left;
397 winRect->top -= tmpRect.top;
398 winRect->right -= tmpRect.right;
399 winRect->bottom -= tmpRect.bottom;
400 }
401
402 return result;
403}
404//******************************************************************************
405//******************************************************************************
406LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
407{
408 RECT rect = rectWindow;
409
410 if (!PtInRect(&rect,pt)) return HTNOWHERE;
411
412 if (dwStyle & WS_MINIMIZE) return HTCAPTION;
413
414 if (!(flags & WIN_MANAGED))
415 {
416 /* Check borders */
417 if (HAS_THICKFRAME(dwStyle,dwExStyle))
418 {
419 InflateRect(&rect,-GetSystemMetrics(SM_CXFRAME),-GetSystemMetrics(SM_CYFRAME));
420 if (!PtInRect(&rect,pt))
421 {
422 /* Check top sizing border */
423 if (pt.y < rect.top)
424 {
425 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
426 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
427 return HTTOP;
428 }
429 /* Check bottom sizing border */
430 if (pt.y >= rect.bottom)
431 {
432 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
433 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
434 return HTBOTTOM;
435 }
436 /* Check left sizing border */
437 if (pt.x < rect.left)
438 {
439 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
440 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
441 return HTLEFT;
442 }
443 /* Check right sizing border */
444 if (pt.x >= rect.right)
445 {
446 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
447 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
448 return HTRIGHT;
449 }
450 }
451 } else /* No thick frame */
452 {
453 if (HAS_DLGFRAME(dwStyle,dwExStyle))
454 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
455 else if (HAS_THINFRAME(dwStyle ))
456 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
457 if (!PtInRect( &rect, pt )) return HTBORDER;
458 }
459
460 /* Check caption */
461
462 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
463 {
464 if (dwExStyle & WS_EX_TOOLWINDOW)
465 rect.top += GetSystemMetrics(SM_CYSMCAPTION)-1;
466 else
467 rect.top += GetSystemMetrics(SM_CYCAPTION)-1;
468 if (!PtInRect(&rect,pt))
469 {
470 /* Check system menu */
471 if(dwStyle & WS_SYSMENU)
472 {
473 /* Check if there is an user icon */
474 HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
475 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
476
477 /* If there is an icon associated with the window OR */
478 /* If there is no hIcon specified and this is not a modal dialog, */
479 /* there is a system menu icon. */
480 if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
481 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
482 }
483 if (pt.x < rect.left) return HTSYSMENU;
484
485 /* Check close button */
486 if (dwStyle & WS_SYSMENU)
487 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
488 if (pt.x > rect.right) return HTCLOSE;
489
490 /* Check maximize box */
491 /* In win95 there is automatically a Maximize button when there is a minimize one*/
492 if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
493 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
494 if (pt.x > rect.right) return HTMAXBUTTON;
495
496 /* Check minimize box */
497 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
498 if ((dwStyle & WS_MINIMIZEBOX)||(dwStyle & WS_MAXIMIZEBOX))
499 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
500
501 if (pt.x > rect.right) return HTMINBUTTON;
502 return HTCAPTION;
503 }
504 }
505 }
506
507 /* Check client area */
508
509 ScreenToClient(Win32Hwnd,&pt);
510 getClientRect(&rect);
511 if (PtInRect(&rect,pt)) return HTCLIENT;
512
513 /* Check vertical scroll bar */
514
515 if (dwStyle & WS_VSCROLL)
516 {
517 rect.right += GetSystemMetrics(SM_CXVSCROLL);
518 if (PtInRect( &rect, pt )) return HTVSCROLL;
519 }
520
521 /* Check horizontal scroll bar */
522
523 if (dwStyle & WS_HSCROLL)
524 {
525 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
526 if (PtInRect( &rect, pt ))
527 {
528 /* Check size box */
529 if ((dwStyle & WS_VSCROLL) &&
530 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
531 return (dwStyle & WS_CHILD) ? HTSIZE:HTBOTTOMRIGHT;
532 return HTHSCROLL;
533 }
534 }
535
536 /* Check menu bar */
537
538 if (HAS_MENU())
539 {
540 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
541 return HTMENU;
542 }
543
544 /* Should never get here */
545 return HTERROR;
546}
547
548//******************************************************************************
549//******************************************************************************
550VOID Win32BaseWindow::GetInsideRect(RECT *rect)
551{
552 rect->top = rect->left = 0;
553 rect->right = rectWindow.right - rectWindow.left;
554 rect->bottom = rectWindow.bottom - rectWindow.top;
555
556 if ((dwStyle & WS_ICONIC) || (flags & WIN_MANAGED)) return;
557
558 /* Remove frame from rectangle */
559 if (HAS_THICKFRAME(dwStyle,dwExStyle))
560 {
561 InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
562 }
563 else if (HAS_DLGFRAME(dwStyle,dwExStyle ))
564 {
565 InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
566 }
567 else if (HAS_THINFRAME(dwStyle))
568 {
569 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
570 }
571
572 /* We have additional border information if the window
573 * is a child (but not an MDI child) */
574 if ( (dwStyle & WS_CHILD) &&
575 ( (dwExStyle & WS_EX_MDICHILD) == 0 ) )
576 {
577 if (dwExStyle & WS_EX_CLIENTEDGE)
578 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
579
580 if (dwExStyle & WS_EX_STATICEDGE)
581 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
582 }
583}
584//******************************************************************************
585//******************************************************************************
586VOID Win32BaseWindow::DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active)
587{
588 INT width, height;
589 HBRUSH oldBrush;
590
591 if (dlgFrame)
592 {
593 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
594 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
595 }
596 else
597 {
598 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
599 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
600 }
601
602 oldBrush = SelectObject(hdc,GetSysColorBrush(active ? COLOR_ACTIVEBORDER:COLOR_INACTIVEBORDER));
603
604 /* Draw frame */
605 PatBlt(hdc,rect->left, rect->top, rect->right-rect->left, height,PATCOPY);
606 PatBlt(hdc,rect->left, rect->top, width, rect->bottom-rect->top,PATCOPY);
607 PatBlt(hdc,rect->left, rect->bottom-1, rect->right-rect->left,-height,PATCOPY);
608 PatBlt(hdc,rect->right-1,rect->top, -width, rect->bottom-rect->top,PATCOPY);
609 SelectObject(hdc,oldBrush);
610
611 InflateRect(rect,-width,-height);
612}
613//******************************************************************************
614//******************************************************************************
615BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
616{
617 if(!(flags & WIN_MANAGED))
618 {
619 HICON hIcon;
620 RECT r;
621
622 if (!rect) GetInsideRect(&r);
623 else r = *rect;
624
625 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
626 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
627
628 /* If there is no hIcon specified or this is not a modal dialog, */
629 /* get the default one. */
630 if(hIcon == 0)
631 if (!(dwStyle & DS_MODALFRAME))
632 hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
633
634 if (hIcon)
635 DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
636 GetSystemMetrics(SM_CXSMICON),
637 GetSystemMetrics(SM_CYSMICON),
638 0, 0, DI_NORMAL);
639
640 return (hIcon != 0);
641 }
642 return FALSE;
643}
644//******************************************************************************
645//******************************************************************************
646BOOL Win32BaseWindow::GetSysPopupPos(RECT* rect)
647{
648 if(hSysMenu)
649 {
650 if(dwStyle & WS_MINIMIZE )
651 *rect = rectWindow;
652 else
653 {
654 GetInsideRect(rect );
655 OffsetRect( rect, rectWindow.left, rectWindow.top);
656 rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
657 rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
658 }
659 return TRUE;
660 }
661 return FALSE;
662}
663//******************************************************************************
664//******************************************************************************
665BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
666{
667 HBITMAP hMaskBmp;
668 HDC hdcMask = CreateCompatibleDC (0);
669 HBRUSH hOldBrush;
670 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
671
672 if(hMaskBmp == 0)
673 return FALSE;
674
675 SelectObject (hdcMask, hMaskBmp);
676
677 /* Draw the grayed bitmap using the mask */
678 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
679 BitBlt (hdc, x, y, 12, 10,
680 hdcMask, 0, 0, 0xB8074A);
681
682 /* Clean up */
683 SelectObject (hdc, hOldBrush);
684 DeleteObject(hMaskBmp);
685 DeleteDC (hdcMask);
686
687 return TRUE;
688}
689//******************************************************************************
690//******************************************************************************
691VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
692{
693 RECT r;
694 HDC hdcMem;
695
696 if( !(flags & WIN_MANAGED) )
697 {
698 BITMAP bmp;
699 HBITMAP hBmp, hOldBmp;
700
701 if (!rect) GetInsideRect(&r);
702 else r = *rect;
703
704 hdcMem = CreateCompatibleDC( hdc );
705 hBmp = down ? hbitmapCloseD : hbitmapClose;
706 hOldBmp = SelectObject (hdcMem, hBmp);
707 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
708
709 BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
710 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
711 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
712
713 if(bGrayed)
714 DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
715 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
716
717 SelectObject (hdcMem, hOldBmp);
718 DeleteDC (hdcMem);
719 }
720}
721//******************************************************************************
722//******************************************************************************
723VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
724{
725 RECT r;
726 HDC hdcMem;
727
728 if( !(flags & WIN_MANAGED))
729 {
730 BITMAP bmp;
731 HBITMAP hBmp,hOldBmp;
732
733 if (!rect) GetInsideRect(&r);
734 else r = *rect;
735 hdcMem = CreateCompatibleDC( hdc );
736 hBmp = IsZoomed(Win32Hwnd) ?
737 (down ? hbitmapRestoreD : hbitmapRestore ) :
738 (down ? hbitmapMaximizeD: hbitmapMaximize);
739 hOldBmp=SelectObject( hdcMem, hBmp );
740 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
741
742 if (dwStyle & WS_SYSMENU)
743 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
744
745 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
746 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
747 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
748
749 if(bGrayed)
750 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
751 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
752
753
754 SelectObject (hdcMem, hOldBmp);
755 DeleteDC( hdcMem );
756 }
757}
758//******************************************************************************
759//******************************************************************************
760VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
761{
762 RECT r;
763 HDC hdcMem;
764
765 if( !(flags & WIN_MANAGED))
766
767 {
768 BITMAP bmp;
769 HBITMAP hBmp,hOldBmp;
770
771 if (!rect) GetInsideRect(&r);
772 else r = *rect;
773
774 hdcMem = CreateCompatibleDC( hdc );
775 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
776 hOldBmp= SelectObject( hdcMem, hBmp );
777 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
778
779 if (dwStyle & WS_SYSMENU)
780 r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
781
782 /* In win 95 there is always a Maximize box when there is a Minimize one */
783 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
784 r.right -= bmp.bmWidth;
785
786 BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
787 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
788 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
789
790 if(bGrayed)
791 DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
792 r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
793
794
795 SelectObject (hdcMem, hOldBmp);
796 DeleteDC( hdcMem );
797 }
798}
799//******************************************************************************
800// redrawText: only redraws text
801//******************************************************************************
802VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText)
803{
804 RECT r = *rect,r2;
805 char buffer[256];
806 HPEN hPrevPen;
807 HDC memDC;
808 HBITMAP memBmp,oldBmp;
809
810 if (flags & WIN_MANAGED) return;
811
812 memDC = CreateCompatibleDC(hdc);
813 r.right -= r.left;
814 r.bottom -= r.top;
815 r.left = r.top = 0;
816 r2 = r;
817 memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom);
818 oldBmp = SelectObject(memDC,memBmp);
819
820 hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
821 MoveToEx(memDC,r.left,r.bottom-1,NULL);
822 LineTo(memDC,r.right,r.bottom-1);
823 SelectObject(memDC,hPrevPen);
824 r.bottom--;
825
826 if (SYSCOLOR_GetUseWinColors())
827 {
828 COLORREF startColor = GetSysColor(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION),endColor = GetSysColor(active ? COLOR_GRADIENTACTIVECAPTION:COLOR_GRADIENTINACTIVECAPTION);
829
830 if (startColor == endColor)
831 FillRect(memDC,&r,GetSysColorBrush(startColor));
832 else
833 {
834 INT rDiff = GetRValue(endColor)-GetRValue(startColor);
835 INT gDiff = GetGValue(endColor)-GetGValue(startColor);
836 INT bDiff = GetBValue(endColor)-GetBValue(startColor);
837 INT steps = MAX(MAX(abs(rDiff),abs(gDiff)),abs(bDiff));
838 INT w = r.right-r.left;
839 RECT r2;
840
841 if (w < steps) steps = w;
842 r2.left = r2.right = r.left;
843 r2.top = r.top;
844 r2.bottom = r.bottom;
845 for (INT x = 0;x <= steps;x++)
846 {
847 COLORREF color = RGB(GetRValue(startColor)+rDiff*x/steps,GetGValue(startColor)+gDiff*x/steps,GetBValue(startColor)+bDiff*x/steps);
848 HBRUSH brush = CreateSolidBrush(color);
849
850 r2.left = r2.right;
851 r2.right = r.left+w*x/steps;
852 FillRect(memDC,&r2,brush);
853 DeleteObject(brush);
854 }
855 }
856 } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
857
858 if (!hbitmapClose)
859 {
860 if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
861 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
862 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
863 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
864 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
865 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
866 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
867 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
868 }
869
870 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
871 {
872 if (redrawText || DrawSysButton(memDC,&r))
873 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
874 }
875
876 if (dwStyle & WS_SYSMENU)
877 {
878 UINT state;
879
880 if (!redrawText)
881 {
882 /* Go get the sysmenu */
883 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
884
885 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
886 DrawCloseButton(memDC,&r2,FALSE,
887 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
888 }
889 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
890
891 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
892 {
893 /* In win95 the two buttons are always there */
894 /* But if the menu item is not in the menu they're disabled*/
895
896 if (!redrawText)
897 DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));
898 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
899
900 if (!redrawText)
901 DrawMinButton(memDC,&r2,FALSE, (!(dwStyle & WS_MINIMIZEBOX)));
902 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
903 }
904 }
905
906 if (GetWindowTextA(buffer, sizeof(buffer) ))
907 {
908 NONCLIENTMETRICSA nclm;
909 HFONT hFont, hOldFont;
910
911 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
912 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
913 if (dwExStyle & WS_EX_TOOLWINDOW)
914 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
915 else
916 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
917 hOldFont = SelectObject (memDC, hFont);
918 SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
919 SetBkMode(memDC, TRANSPARENT );
920 r.left += 2;
921 DrawTextA(memDC, buffer, -1, &r,
922 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
923 DeleteObject (SelectObject (memDC, hOldFont));
924 }
925
926 BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
927 SelectObject(memDC,oldBmp);
928 DeleteObject(memBmp);
929 DeleteDC(memDC);
930}
931//******************************************************************************
932//******************************************************************************
933VOID Win32BaseWindow::UpdateCaptionText()
934{
935 BOOL active = flags & WIN_NCACTIVATED;
936 HDC hdc;
937 RECT rect,r;
938 HRGN hrgn;
939
940 if (!((dwStyle & WS_CAPTION) == WS_CAPTION)) return;
941
942 rect.top = rect.left = 0;
943 rect.right = rectWindow.right - rectWindow.left;
944 rect.bottom = rectWindow.bottom - rectWindow.top;
945 if(!(flags & WIN_MANAGED))
946 {
947 if (HAS_BIGFRAME( dwStyle, dwExStyle))
948 {
949 InflateRect(&rect,-2,-2);
950 }
951
952 if (HAS_THICKFRAME(dwStyle,dwExStyle))
953 {
954 INT width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
955 INT height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
956
957 InflateRect(&rect,-width,-height);
958 }
959 else if (HAS_DLGFRAME(dwStyle,dwExStyle))
960 {
961 INT width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
962 INT height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
963
964 InflateRect(&rect,-width,-height);
965 }
966 else if (HAS_THINFRAME(dwStyle))
967 {
968 }
969
970 r = rect;
971 if (dwExStyle & WS_EX_TOOLWINDOW)
972 {
973 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
974 }
975 else
976 {
977 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
978 }
979
980 //clip the buttons
981 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
982 {
983 HICON hIcon;
984
985 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
986 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
987 if (hIcon)
988 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
989 }
990 if (dwStyle & WS_SYSMENU)
991 {
992 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
993
994 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
995 {
996 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
997 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
998 }
999 }
1000
1001 hrgn = CreateRectRgnIndirect(&rect);
1002 hdc = GetDCEx(Win32Hwnd,hrgn,DCX_USESTYLE | DCX_WINDOW | DCX_INTERSECTRGN);
1003 SelectObject(hdc,GetSysColorPen(COLOR_WINDOWFRAME));
1004 DrawCaption(hdc,&r,active,TRUE);
1005 DeleteObject(hrgn);
1006 ReleaseDC(Win32Hwnd,hdc);
1007 }
1008}
1009//******************************************************************************
1010//******************************************************************************
1011VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
1012{
1013 BOOL active = flags & WIN_NCACTIVATED;
1014 HDC hdc;
1015 RECT rect,rectClip,rfuzz;
1016
1017 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1018 the call to GetDCEx implying that it is allowed not to use it either.
1019 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1020 will cause clipRgn to be deleted after ReleaseDC().
1021 Now, how is the "system" supposed to tell what happened?
1022 */
1023
1024 if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
1025 ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
1026
1027 rect.top = rect.left = 0;
1028 rect.right = rectWindow.right - rectWindow.left;
1029 rect.bottom = rectWindow.bottom - rectWindow.top;
1030
1031 if( clip > 1 )
1032 {
1033 //CB: unknown WINE handling (clip == 1), clip client?
1034 GetRgnBox( clip, &rectClip );
1035 } else
1036 {
1037 clip = 0;
1038 rectClip = rect;
1039 }
1040
1041 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
1042
1043 if(!(flags & WIN_MANAGED))
1044 {
1045 if (HAS_BIGFRAME( dwStyle, dwExStyle))
1046 {
1047 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1048 }
1049 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
1050 DrawFrame(hdc, &rect, FALSE, active );
1051 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
1052 DrawFrame( hdc, &rect, TRUE, active );
1053 else if (HAS_THINFRAME( dwStyle ))
1054 {
1055 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
1056 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
1057 }
1058
1059 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1060 {
1061 RECT r = rect;
1062 if (dwExStyle & WS_EX_TOOLWINDOW)
1063 {
1064 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1065 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1066 }
1067 else
1068 {
1069 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1070 rect.top += GetSystemMetrics(SM_CYCAPTION);
1071 }
1072 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1073 DrawCaption(hdc,&r,active,FALSE);
1074 }
1075 }
1076 if (HAS_MENU())
1077 {
1078 RECT r = rect;
1079 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1080
1081 rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
1082 }
1083
1084 if (dwExStyle & WS_EX_CLIENTEDGE)
1085 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1086
1087 if (dwExStyle & WS_EX_STATICEDGE)
1088 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1089
1090 /* Draw the scroll-bars */
1091 if (dwStyle & WS_VSCROLL)
1092 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
1093 if (dwStyle & WS_HSCROLL)
1094 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
1095
1096 /* Draw the "size-box" */
1097 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
1098 {
1099 RECT r = rect;
1100 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1101 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1102 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1103 if (!(dwStyle & WS_CHILD))
1104 {
1105 POINT p1,p2;
1106 HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
1107 HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
1108 HPEN oldPen = SelectObject(hdc,penDark);
1109 INT x;
1110
1111 p1.x = r.right-1;
1112 p1.y = r.bottom;
1113 p2.x = r.right;
1114 p2.y = r.bottom-1;
1115 for (x = 0;x < 3;x++)
1116 {
1117 SelectObject(hdc,penDark);
1118 MoveToEx(hdc,p1.x,p1.y,NULL);
1119 LineTo(hdc,p2.x,p2.y);
1120 p1.x--;
1121 p2.y--;
1122 MoveToEx(hdc,p1.x,p1.y,NULL);
1123 LineTo(hdc,p2.x,p2.y);
1124 SelectObject(hdc,penWhite);
1125 p1.x--;
1126 p2.y--;
1127 MoveToEx(hdc,p1.x,p1.y,NULL);
1128 LineTo(hdc,p2.x,p2.y);
1129 p1.x -= 2;
1130 p2.y -= 2;
1131 }
1132
1133 SelectObject(hdc,oldPen);
1134 }
1135 }
1136
1137 ReleaseDC(Win32Hwnd,hdc);
1138}
1139//******************************************************************************
1140//******************************************************************************
1141LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
1142{
1143//CB: ignore it for now (SetWindowPos in WM_CREATE)
1144// if (!(dwStyle & WS_VISIBLE)) return 0;
1145
1146 if (dwStyle & WS_MINIMIZE) return 0;
1147
1148 DoNCPaint(clip,FALSE);
1149
1150 return 0;
1151}
1152/***********************************************************************
1153 * NC_HandleNCLButtonDblClk
1154 *
1155 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1156 */
1157LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
1158{
1159 /*
1160 * if this is an icon, send a restore since we are handling
1161 * a double click
1162 */
1163 if (dwStyle & WS_MINIMIZE)
1164 {
1165 SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
1166 return 0;
1167 }
1168
1169 switch(wParam) /* Hit test */
1170 {
1171 case HTCAPTION:
1172 /* stop processing if WS_MAXIMIZEBOX is missing */
1173 if (dwStyle & WS_MAXIMIZEBOX)
1174 SendInternalMessageA(WM_SYSCOMMAND,
1175 (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
1176 lParam);
1177 break;
1178
1179 case HTSYSMENU:
1180 if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
1181 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
1182 break;
1183
1184 case HTHSCROLL:
1185 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
1186 break;
1187
1188 case HTVSCROLL:
1189 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
1190 break;
1191 }
1192
1193 return 0;
1194}
1195//******************************************************************************
1196//******************************************************************************
1197LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
1198{
1199 if (wParam == HTCAPTION)
1200 {
1201 if (GetActiveWindow() != Win32Hwnd)
1202 SetActiveWindow();
1203
1204 if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
1205 {
1206 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
1207 }
1208 }
1209
1210 return 0;
1211}
1212/***********************************************************************
1213 * NC_HandleSysCommand
1214 *
1215 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1216 *
1217 */
1218LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
1219{
1220 UINT uCommand = wParam & 0xFFF0;
1221
1222 switch (uCommand)
1223 {
1224
1225 case SC_SIZE:
1226 {
1227 DWORD flags = 0;
1228
1229 switch ((wParam & 0xF)+2)
1230 {
1231 case HTLEFT:
1232 flags = TFOS_LEFT;
1233 break;
1234
1235 case HTRIGHT:
1236 flags = TFOS_RIGHT;
1237 break;
1238
1239 case HTTOP:
1240 flags = TFOS_TOP;
1241 break;
1242
1243 case HTTOPLEFT:
1244 flags = TFOS_TOP | TFOS_LEFT;
1245 break;
1246
1247 case HTTOPRIGHT:
1248 flags = TFOS_TOP | TFOS_RIGHT;
1249 break;
1250
1251 case HTBOTTOM:
1252 flags = TFOS_BOTTOM;
1253 break;
1254
1255 case HTBOTTOMLEFT:
1256 flags = TFOS_BOTTOM | TFOS_LEFT;
1257 break;
1258
1259 case HTBOTTOMRIGHT:
1260 flags = TFOS_BOTTOM | TFOS_RIGHT;
1261 break;
1262 }
1263 if (flags) FrameTrackFrame(this,flags);
1264 break;
1265 }
1266
1267 case SC_MOVE:
1268 FrameTrackFrame(this,TFOS_MOVE);
1269 break;
1270
1271 case SC_MINIMIZE:
1272 ShowWindow(SW_MINIMIZE);
1273 break;
1274
1275 case SC_MAXIMIZE:
1276 ShowWindow(SW_MAXIMIZE);
1277 break;
1278
1279 case SC_RESTORE:
1280 ShowWindow(SW_RESTORE);
1281 break;
1282
1283 case SC_CLOSE:
1284 return SendInternalMessageA(WM_CLOSE,0,0);
1285
1286 case SC_VSCROLL:
1287 case SC_HSCROLL:
1288 TrackScrollBar(wParam,*pt32);
1289 break;
1290
1291 case SC_MOUSEMENU:
1292 MENU_TrackMouseMenuBar(Win32Hwnd,wParam & 0x000F,*pt32);
1293 break;
1294
1295 case SC_KEYMENU:
1296 MENU_TrackKbdMenuBar(Win32Hwnd,wParam,pt32->x);
1297 break;
1298
1299 case SC_TASKLIST:
1300 OSLibWinShowTaskList(getOS2FrameWindowHandle());
1301 break;
1302
1303 case SC_SCREENSAVE:
1304 if (wParam == SC_ABOUTODIN) {
1305 if(ShellAboutA == 0) {
1306 HINSTANCE hShell32 = LoadLibraryA("SHELL32");
1307 if(hShell32 == 0)
1308 break;
1309 *(VOID **)&ShellAboutA = (VOID *)GetProcAddress(hShell32, "ShellAboutA");
1310 }
1311 ShellAboutA(Win32Hwnd,"Odin","Odin alpha release compiled with IBM VAC++",0);
1312 }
1313 else
1314 if (wParam == SC_PUTMARK)
1315 dprintf(("Mark requested by user\n"));
1316 break;
1317
1318 case SC_HOTKEY:
1319 case SC_ARRANGE:
1320 case SC_NEXTWINDOW:
1321 case SC_PREVWINDOW:
1322 break;
1323 }
1324 return 0;
1325}
1326//******************************************************************************
1327//******************************************************************************
Note: See TracBrowser for help on using the repository browser.