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

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

WM_EX_CONTEXTHELP

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