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