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