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