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

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

cvs merge messed things up

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