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

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

DrawCaption performance improvements for window text updates

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