source: trunk/src/user32/win32wbasenonclient.cpp@ 2739

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

menu and titlebar fix, some new stubs

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