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

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

refixed WM_WINDOWPOS*

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