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

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

several fixes -> changelog

File size: 38.5 KB
Line 
1/* $Id: win32wbasenonclient.cpp,v 1.9 2000-02-05 19:45:19 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 DrawTextA(memDC, buffer, -1, &r,
935 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
936 DeleteObject (SelectObject (memDC, hOldFont));
937 }
938
939 BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
940 SelectObject(memDC,oldBmp);
941 DeleteObject(memBmp);
942 DeleteDC(memDC);
943}
944//******************************************************************************
945//******************************************************************************
946VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
947{
948 BOOL active = flags & WIN_NCACTIVATED;
949 HDC hdc;
950 RECT rect,rectClip,rfuzz;
951
952 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
953 the call to GetDCEx implying that it is allowed not to use it either.
954 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
955 will cause clipRgn to be deleted after ReleaseDC().
956 Now, how is the "system" supposed to tell what happened?
957 */
958
959 dprintf(("DoNCPaint %x %x %d", getWindowHandle(), clip, suppress_menupaint));
960
961 if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
962 ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
963
964 rect.top = rect.left = 0;
965 rect.right = rectWindow.right - rectWindow.left;
966 rect.bottom = rectWindow.bottom - rectWindow.top;
967
968 if (clip > 1)
969 {
970 //only redraw caption
971 GetRgnBox(clip,&rectClip);
972 }
973 else
974 {
975 clip = 0;
976 rectClip = rect;
977 }
978
979 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
980
981 if (HAS_BIGFRAME( dwStyle, dwExStyle))
982 {
983 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
984 }
985 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
986 DrawFrame(hdc, &rect, FALSE, active );
987 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
988 DrawFrame( hdc, &rect, TRUE, active );
989 else if (HAS_THINFRAME( dwStyle ))
990 {
991 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
992 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
993 }
994
995 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
996 {
997 RECT r = rect;
998 if (dwExStyle & WS_EX_TOOLWINDOW)
999 {
1000 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
1001 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
1002 }
1003 else
1004 {
1005 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
1006 rect.top += GetSystemMetrics(SM_CYCAPTION);
1007 }
1008 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
1009 DrawCaption(hdc,&r,active);
1010 }
1011
1012 if (HAS_MENU())
1013 {
1014 RECT r = rect;
1015 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
1016
1017 rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
1018 }
1019
1020 if (dwExStyle & WS_EX_CLIENTEDGE)
1021 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1022
1023 if (dwExStyle & WS_EX_STATICEDGE)
1024 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
1025
1026 /* Draw the scroll-bars */
1027 if (dwStyle & WS_VSCROLL)
1028 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
1029 if (dwStyle & WS_HSCROLL)
1030 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
1031
1032 /* Draw the "size-box" */
1033 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
1034 {
1035 RECT r = rect;
1036 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
1037 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
1038 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
1039 if (!(dwStyle & WS_CHILD))
1040 {
1041 POINT p1,p2;
1042 HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
1043 HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
1044 HPEN oldPen = SelectObject(hdc,penDark);
1045 INT x;
1046
1047 p1.x = r.right-1;
1048 p1.y = r.bottom;
1049 p2.x = r.right;
1050 p2.y = r.bottom-1;
1051 for (x = 0;x < 3;x++)
1052 {
1053 SelectObject(hdc,penDark);
1054 MoveToEx(hdc,p1.x,p1.y,NULL);
1055 LineTo(hdc,p2.x,p2.y);
1056 p1.x--;
1057 p2.y--;
1058 MoveToEx(hdc,p1.x,p1.y,NULL);
1059 LineTo(hdc,p2.x,p2.y);
1060 SelectObject(hdc,penWhite);
1061 p1.x--;
1062 p2.y--;
1063 MoveToEx(hdc,p1.x,p1.y,NULL);
1064 LineTo(hdc,p2.x,p2.y);
1065 p1.x -= 2;
1066 p2.y -= 2;
1067 }
1068
1069 SelectObject(hdc,oldPen);
1070 }
1071 }
1072
1073 ReleaseDC(Win32Hwnd,hdc);
1074 dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
1075}
1076//******************************************************************************
1077//******************************************************************************
1078LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
1079{
1080//CB: ignore it for now (SetWindowPos in WM_CREATE)
1081// if (!(dwStyle & WS_VISIBLE)) return 0;
1082
1083 if (dwStyle & WS_MINIMIZE) return 0;
1084
1085 DoNCPaint(clip,FALSE);
1086
1087 return 0;
1088}
1089/***********************************************************************
1090 * NC_HandleNCLButtonDblClk
1091 *
1092 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
1093 */
1094LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
1095{
1096 /*
1097 * if this is an icon, send a restore since we are handling
1098 * a double click
1099 */
1100 if (dwStyle & WS_MINIMIZE)
1101 {
1102 SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
1103 return 0;
1104 }
1105
1106 switch(wParam) /* Hit test */
1107 {
1108 case HTCAPTION:
1109 /* stop processing if WS_MAXIMIZEBOX is missing */
1110 if (dwStyle & WS_MAXIMIZEBOX)
1111 SendInternalMessageA(WM_SYSCOMMAND,
1112 (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
1113 lParam);
1114 break;
1115
1116 case HTSYSMENU:
1117 if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
1118 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
1119 break;
1120
1121 case HTHSCROLL:
1122 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
1123 break;
1124
1125 case HTVSCROLL:
1126 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
1127 break;
1128 }
1129
1130 return 0;
1131}
1132//******************************************************************************
1133//******************************************************************************
1134LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
1135{
1136 switch(wParam)
1137 {
1138 case HTCAPTION:
1139 if (GetActiveWindow() != Win32Hwnd)
1140 SetActiveWindow();
1141
1142 if (((GetActiveWindow() == Win32Hwnd) || isMDIChild()) && (dwStyle & WS_SYSMENU))
1143 {
1144 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
1145 }
1146 break;
1147
1148 default:
1149 break;
1150 }
1151
1152 return 0;
1153}
1154/***********************************************************************
1155 * NC_HandleSysCommand
1156 *
1157 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
1158 *
1159 */
1160LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
1161{
1162 UINT uCommand = wParam & 0xFFF0;
1163
1164 switch (uCommand)
1165 {
1166
1167 case SC_SIZE:
1168 {
1169 DWORD flags;
1170
1171 if (dwStyle & WS_MAXIMIZE) break;
1172
1173 switch ((wParam & 0xF)+2)
1174 {
1175 case HTLEFT:
1176 flags = TFOS_LEFT;
1177 break;
1178
1179 case HTRIGHT:
1180 flags = TFOS_RIGHT;
1181 break;
1182
1183 case HTTOP:
1184 flags = TFOS_TOP;
1185 break;
1186
1187 case HTTOPLEFT:
1188 flags = TFOS_TOP | TFOS_LEFT;
1189 break;
1190
1191 case HTTOPRIGHT:
1192 flags = TFOS_TOP | TFOS_RIGHT;
1193 break;
1194
1195 case HTBOTTOM:
1196 flags = TFOS_BOTTOM;
1197 break;
1198
1199 case HTBOTTOMLEFT:
1200 flags = TFOS_BOTTOM | TFOS_LEFT;
1201 break;
1202
1203 case HTBOTTOMRIGHT:
1204 flags = TFOS_BOTTOM | TFOS_RIGHT;
1205 break;
1206
1207 default:
1208 flags = TFOS_BOTTOM | TFOS_RIGHT;
1209 break;
1210 }
1211 if (flags) FrameTrackFrame(this,flags);
1212 break;
1213 }
1214
1215 case SC_MOVE:
1216 if (dwStyle & WS_MAXIMIZE) break;
1217 FrameTrackFrame(this,TFOS_MOVE);
1218 break;
1219
1220 case SC_MINIMIZE:
1221 ShowWindow(SW_MINIMIZE);
1222 break;
1223
1224 case SC_MAXIMIZE:
1225 ShowWindow(SW_MAXIMIZE);
1226 break;
1227
1228 case SC_RESTORE:
1229 ShowWindow(SW_RESTORE);
1230 break;
1231
1232 case SC_CLOSE:
1233 return SendInternalMessageA(WM_CLOSE,0,0);
1234
1235 case SC_VSCROLL:
1236 case SC_HSCROLL:
1237 TrackScrollBar(wParam,*pt32);
1238 break;
1239
1240 case SC_MOUSEMENU:
1241 MENU_TrackMouseMenuBar(Win32Hwnd,wParam & 0x000F,*pt32);
1242 break;
1243
1244 case SC_KEYMENU:
1245 MENU_TrackKbdMenuBar(Win32Hwnd,wParam,pt32->x);
1246 break;
1247
1248 case SC_TASKLIST:
1249 OSLibWinShowTaskList(getOS2FrameWindowHandle());
1250 break;
1251
1252 case SC_SCREENSAVE:
1253 if (wParam == SC_ABOUTODIN) {
1254 if(ShellAboutA == 0) {
1255 HINSTANCE hShell32 = LoadLibraryA("SHELL32");
1256 if(hShell32 == 0)
1257 break;
1258 *(VOID **)&ShellAboutA = (VOID *)GetProcAddress(hShell32, "ShellAboutA");
1259 }
1260 ShellAboutA(Win32Hwnd,"Odin","Odin alpha release compiled with IBM VAC++",0);
1261 }
1262 else
1263 if (wParam == SC_PUTMARK)
1264 dprintf(("Mark requested by user\n"));
1265 break;
1266
1267 case SC_HOTKEY:
1268 case SC_ARRANGE:
1269 case SC_NEXTWINDOW:
1270 case SC_PREVWINDOW:
1271 break;
1272 }
1273 return 0;
1274}
1275//******************************************************************************
1276//******************************************************************************
Note: See TracBrowser for help on using the repository browser.