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

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

several nc changes

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