| 1 | /* $Id: comctl32.c,v 1.7 1999-06-25 15:49:01 achimha Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 common controls implementation
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (C) 1999 Achim Hasenmueller
|
|---|
| 6 | *
|
|---|
| 7 | * Based on the work of the WINE group (www.winehq.com)
|
|---|
| 8 | *
|
|---|
| 9 | *
|
|---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #include "comctl32.h"
|
|---|
| 15 | #include "winerror.h"
|
|---|
| 16 | #include "progress.h"
|
|---|
| 17 | #include "comboex.h"
|
|---|
| 18 | #include "animate.h"
|
|---|
| 19 | #include "datetime.h"
|
|---|
| 20 | #include "flatsb.h"
|
|---|
| 21 | #include "hotkey.h"
|
|---|
| 22 | #include "ipaddress.h"
|
|---|
| 23 | #include "monthcal.h"
|
|---|
| 24 | #include "nativefont.h"
|
|---|
| 25 | #include "pager.h"
|
|---|
| 26 | #include "tab.h"
|
|---|
| 27 | #include "status.h"
|
|---|
| 28 | #include "header.h"
|
|---|
| 29 | #include "updown.h"
|
|---|
| 30 | #include "rebar.h"
|
|---|
| 31 | #include "trackbar.h"
|
|---|
| 32 | #include "tooltips.h"
|
|---|
| 33 | #include "toolbar.h"
|
|---|
| 34 | #include "treeview.h"
|
|---|
| 35 |
|
|---|
| 36 | HANDLE COMCTL32_hHeap = (HANDLE)NULL;
|
|---|
| 37 | HMODULE COMCTL32_hModule = 0;
|
|---|
| 38 | LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
|
|---|
| 39 |
|
|---|
| 40 | void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL)
|
|---|
| 41 | {
|
|---|
| 42 | /* create private heap */
|
|---|
| 43 | COMCTL32_hHeap = HeapCreate(0, 0x10000, 0);
|
|---|
| 44 | /* add global subclassing atom (used by 'tooltip' and 'updown') */
|
|---|
| 45 | COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
|
|---|
| 46 | /* This will be wrong for any other process attching in this address-space! */
|
|---|
| 47 | COMCTL32_hModule = (HMODULE)hinstDLL;
|
|---|
| 48 |
|
|---|
| 49 | /* register controls */
|
|---|
| 50 | PROGRESS_Register();
|
|---|
| 51 | COMBOEX_Register();
|
|---|
| 52 | ANIMATE_Register();
|
|---|
| 53 | DATETIME_Register();
|
|---|
| 54 | FLATSB_Register();
|
|---|
| 55 | HOTKEY_Register();
|
|---|
| 56 | IPADDRESS_Register();
|
|---|
| 57 | MONTHCAL_Register();
|
|---|
| 58 | NATIVEFONT_Register();
|
|---|
| 59 | PAGER_Register();
|
|---|
| 60 | TAB_Register();
|
|---|
| 61 | STATUS_Register();
|
|---|
| 62 | HEADER_Register();
|
|---|
| 63 | UPDOWN_Register();
|
|---|
| 64 | REBAR_Register();
|
|---|
| 65 | TRACKBAR_Register();
|
|---|
| 66 | TOOLTIPS_Register();
|
|---|
| 67 | TOOLBAR_Register();
|
|---|
| 68 | TREEVIEW_Register();
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | void CDECL UnregisterCOMCTL32WindowClasses(void)
|
|---|
| 72 | {
|
|---|
| 73 | /* unregister controls */
|
|---|
| 74 | PROGRESS_Unregister();
|
|---|
| 75 | COMBOEX_Unregister();
|
|---|
| 76 | ANIMATE_Unregister();
|
|---|
| 77 | DATETIME_Unregister();
|
|---|
| 78 | FLATSB_Unregister();
|
|---|
| 79 | HOTKEY_Unregister();
|
|---|
| 80 | IPADDRESS_Unregister();
|
|---|
| 81 | MONTHCAL_Unregister();
|
|---|
| 82 | NATIVEFONT_Unregister();
|
|---|
| 83 | PAGER_Unregister();
|
|---|
| 84 | TAB_Unregister();
|
|---|
| 85 | STATUS_Unregister();
|
|---|
| 86 | HEADER_Unregister();
|
|---|
| 87 | UPDOWN_Unregister();
|
|---|
| 88 | REBAR_Unregister();
|
|---|
| 89 | TRACKBAR_Unregister();
|
|---|
| 90 | TOOLTIPS_Unregister();
|
|---|
| 91 | TOOLBAR_Unregister();
|
|---|
| 92 | TREEVIEW_Unregister();
|
|---|
| 93 |
|
|---|
| 94 | /* destroy private heap */
|
|---|
| 95 | HeapDestroy(COMCTL32_hHeap);
|
|---|
| 96 | COMCTL32_hHeap = (HANDLE)NULL;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | /***********************************************************************
|
|---|
| 100 | * MenuHelp [COMCTL32.2]
|
|---|
| 101 | *
|
|---|
| 102 | * PARAMS
|
|---|
| 103 | * uMsg [I] message (WM_MENUSELECT) (see NOTES)
|
|---|
| 104 | * wParam [I] wParam of the message uMsg
|
|---|
| 105 | * lParam [I] lParam of the message uMsg
|
|---|
| 106 | * hMainMenu [I] handle to the application's main menu
|
|---|
| 107 | * hInst [I] handle to the module that contains string resources
|
|---|
| 108 | * hwndStatus [I] handle to the status bar window
|
|---|
| 109 | * lpwIDs [I] pointer to an array of intergers (see NOTES)
|
|---|
| 110 | *
|
|---|
| 111 | * RETURNS
|
|---|
| 112 | * No return value
|
|---|
| 113 | *
|
|---|
| 114 | * NOTES
|
|---|
| 115 | * The official documentation is incomplete!
|
|---|
| 116 | * This is the correct documentation:
|
|---|
| 117 | *
|
|---|
| 118 | * uMsg:
|
|---|
| 119 | * MenuHelp() does NOT handle WM_COMMAND messages! It only handes
|
|---|
| 120 | * WM_MENUSELECT messages.
|
|---|
| 121 | *
|
|---|
| 122 | * lpwIDs:
|
|---|
| 123 | * (will be written ...)
|
|---|
| 124 | */
|
|---|
| 125 |
|
|---|
| 126 | VOID WINAPI
|
|---|
| 127 | MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
|
|---|
| 128 | HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
|
|---|
| 129 | {
|
|---|
| 130 | UINT uMenuID = 0;
|
|---|
| 131 |
|
|---|
| 132 | if (!IsWindow (hwndStatus))
|
|---|
| 133 | return;
|
|---|
| 134 |
|
|---|
| 135 | switch (uMsg) {
|
|---|
| 136 | case WM_MENUSELECT:
|
|---|
| 137 | // TRACE (commctrl, "WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
|
|---|
| 138 | // wParam, lParam);
|
|---|
| 139 |
|
|---|
| 140 | if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
|
|---|
| 141 | /* menu was closed */
|
|---|
| 142 | // TRACE (commctrl, "menu was closed!\n");
|
|---|
| 143 | SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
|
|---|
| 144 | }
|
|---|
| 145 | else {
|
|---|
| 146 | /* menu item was selected */
|
|---|
| 147 | if (HIWORD(wParam) & MF_POPUP)
|
|---|
| 148 | uMenuID = (UINT)*(lpwIDs+1);
|
|---|
| 149 | else
|
|---|
| 150 | uMenuID = (UINT)LOWORD(wParam);
|
|---|
| 151 | // TRACE (commctrl, "uMenuID = %u\n", uMenuID);
|
|---|
| 152 |
|
|---|
| 153 | if (uMenuID) {
|
|---|
| 154 | CHAR szText[256];
|
|---|
| 155 |
|
|---|
| 156 | if (!LoadStringA (hInst, uMenuID, szText, 256))
|
|---|
| 157 | szText[0] = '\0';
|
|---|
| 158 |
|
|---|
| 159 | SendMessageA (hwndStatus, SB_SETTEXTA,
|
|---|
| 160 | 255 | SBT_NOBORDERS, (LPARAM)szText);
|
|---|
| 161 | SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
|
|---|
| 162 | }
|
|---|
| 163 | }
|
|---|
| 164 | break;
|
|---|
| 165 |
|
|---|
| 166 | default:
|
|---|
| 167 | // FIXME (commctrl, "Invalid Message 0x%x!\n", uMsg);
|
|---|
| 168 | break;
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | /***********************************************************************
|
|---|
| 173 | * ShowHideMenuCtl [COMCTL32.3]
|
|---|
| 174 | *
|
|---|
| 175 | * Shows or hides controls and updates the corresponding menu item.
|
|---|
| 176 | *
|
|---|
| 177 | * PARAMS
|
|---|
| 178 | * hwnd [I] handle to the client window.
|
|---|
| 179 | * uFlags [I] menu command id.
|
|---|
| 180 | * lpInfo [I] pointer to an array of integers. (See NOTES.)
|
|---|
| 181 | *
|
|---|
| 182 | * RETURNS
|
|---|
| 183 | * Success: TRUE
|
|---|
| 184 | * Failure: FALSE
|
|---|
| 185 | *
|
|---|
| 186 | * NOTES
|
|---|
| 187 | * The official documentation is incomplete!
|
|---|
| 188 | * This is the correct documentation:
|
|---|
| 189 | *
|
|---|
| 190 | * hwnd
|
|---|
| 191 | * Handle to the window that contains the menu and controls.
|
|---|
| 192 | *
|
|---|
| 193 | * uFlags
|
|---|
| 194 | * Identifier of the menu item to receive or loose a check mark.
|
|---|
| 195 | *
|
|---|
| 196 | * lpInfo
|
|---|
| 197 | * The array of integers contains pairs of values. BOTH values of
|
|---|
| 198 | * the first pair must be the handles to the application's main menu.
|
|---|
| 199 | * Each subsequent pair consists of a menu id and control id.
|
|---|
| 200 | */
|
|---|
| 201 |
|
|---|
| 202 | BOOL WINAPI
|
|---|
| 203 | ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
|
|---|
| 204 | {
|
|---|
| 205 | LPINT lpMenuId;
|
|---|
| 206 |
|
|---|
| 207 | // TRACE (commctrl, "%x, %x, %p\n", hwnd, uFlags, lpInfo);
|
|---|
| 208 |
|
|---|
| 209 | if (lpInfo == NULL)
|
|---|
| 210 | return FALSE;
|
|---|
| 211 |
|
|---|
| 212 | if (!(lpInfo[0]) || !(lpInfo[1]))
|
|---|
| 213 | return FALSE;
|
|---|
| 214 |
|
|---|
| 215 | /* search for control */
|
|---|
| 216 | lpMenuId = &lpInfo[2];
|
|---|
| 217 | while (*lpMenuId != uFlags)
|
|---|
| 218 | lpMenuId += 2;
|
|---|
| 219 |
|
|---|
| 220 | if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
|
|---|
| 221 | /* uncheck menu item */
|
|---|
| 222 | CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
|
|---|
| 223 |
|
|---|
| 224 | /* hide control */
|
|---|
| 225 | lpMenuId++;
|
|---|
| 226 | SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
|
|---|
| 227 | SWP_HIDEWINDOW);
|
|---|
| 228 | }
|
|---|
| 229 | else {
|
|---|
| 230 | /* check menu item */
|
|---|
| 231 | CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
|
|---|
| 232 |
|
|---|
| 233 | /* show control */
|
|---|
| 234 | lpMenuId++;
|
|---|
| 235 | SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
|
|---|
| 236 | SWP_SHOWWINDOW);
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | return TRUE;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | /***********************************************************************
|
|---|
| 243 | * GetEffectiveClientRect [COMCTL32.4]
|
|---|
| 244 | *
|
|---|
| 245 | * PARAMS
|
|---|
| 246 | * hwnd [I] handle to the client window.
|
|---|
| 247 | * lpRect [O] pointer to the rectangle of the client window
|
|---|
| 248 | * lpInfo [I] pointer to an array of integers (see NOTES)
|
|---|
| 249 | *
|
|---|
| 250 | * RETURNS
|
|---|
| 251 | * No return value.
|
|---|
| 252 | *
|
|---|
| 253 | * NOTES
|
|---|
| 254 | * The official documentation is incomplete!
|
|---|
| 255 | * This is the correct documentation:
|
|---|
| 256 | *
|
|---|
| 257 | * lpInfo
|
|---|
| 258 | * (will be written...)
|
|---|
| 259 | */
|
|---|
| 260 |
|
|---|
| 261 | VOID WINAPI
|
|---|
| 262 | GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
|
|---|
| 263 | {
|
|---|
| 264 | RECT rcCtrl;
|
|---|
| 265 | INT *lpRun;
|
|---|
| 266 | HWND hwndCtrl;
|
|---|
| 267 |
|
|---|
| 268 | // TRACE (commctrl, "(0x%08lx 0x%08lx 0x%08lx)\n",
|
|---|
| 269 | // (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
|
|---|
| 270 |
|
|---|
| 271 | GetClientRect (hwnd, lpRect);
|
|---|
| 272 | lpRun = lpInfo;
|
|---|
| 273 |
|
|---|
| 274 | do {
|
|---|
| 275 | lpRun += 2;
|
|---|
| 276 | if (*lpRun == 0)
|
|---|
| 277 | return;
|
|---|
| 278 | lpRun++;
|
|---|
| 279 | hwndCtrl = GetDlgItem (hwnd, *lpRun);
|
|---|
| 280 | if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
|
|---|
| 281 | // TRACE (commctrl, "control id 0x%x\n", *lpRun);
|
|---|
| 282 | GetWindowRect (hwndCtrl, &rcCtrl);
|
|---|
| 283 | MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
|
|---|
| 284 | SubtractRect (lpRect, lpRect, &rcCtrl);
|
|---|
| 285 | }
|
|---|
| 286 | lpRun++;
|
|---|
| 287 | } while (*lpRun);
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | /***********************************************************************
|
|---|
| 291 | * DrawStatusText32A [COMCTL32.5][COMCTL32.27]
|
|---|
| 292 | *
|
|---|
| 293 | * Draws text with borders, like in a status bar.
|
|---|
| 294 | *
|
|---|
| 295 | * PARAMS
|
|---|
| 296 | * hdc [I] handle to the window's display context
|
|---|
| 297 | * lprc [I] pointer to a rectangle
|
|---|
| 298 | * text [I] pointer to the text
|
|---|
| 299 | * style [I] drawing style
|
|---|
| 300 | *
|
|---|
| 301 | * RETURNS
|
|---|
| 302 | * No return value.
|
|---|
| 303 | *
|
|---|
| 304 | * NOTES
|
|---|
| 305 | * The style variable can have one of the following values:
|
|---|
| 306 | * (will be written ...)
|
|---|
| 307 | */
|
|---|
| 308 |
|
|---|
| 309 | VOID WINAPI
|
|---|
| 310 | DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
|
|---|
| 311 | {
|
|---|
| 312 | RECT r = *lprc;
|
|---|
| 313 | UINT border = BDR_SUNKENOUTER;
|
|---|
| 314 |
|
|---|
| 315 | if (style & SBT_POPOUT)
|
|---|
| 316 | border = BDR_RAISEDOUTER;
|
|---|
| 317 | else if (style & SBT_NOBORDERS)
|
|---|
| 318 | border = 0;
|
|---|
| 319 |
|
|---|
| 320 | DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
|
|---|
| 321 |
|
|---|
| 322 | /* now draw text */
|
|---|
| 323 | if (text) {
|
|---|
| 324 | int oldbkmode = SetBkMode (hdc, TRANSPARENT);
|
|---|
| 325 | r.left += 3;
|
|---|
| 326 | DrawTextA (hdc, text, lstrlenA(text),
|
|---|
| 327 | &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
|
|---|
| 328 | if (oldbkmode != TRANSPARENT)
|
|---|
| 329 | SetBkMode(hdc, oldbkmode);
|
|---|
| 330 | }
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 | /***********************************************************************
|
|---|
| 335 | * DrawStatusText32W [COMCTL32.28]
|
|---|
| 336 | *
|
|---|
| 337 | * Draws text with borders, like in a status bar.
|
|---|
| 338 | *
|
|---|
| 339 | * PARAMS
|
|---|
| 340 | * hdc [I] handle to the window's display context
|
|---|
| 341 | * lprc [I] pointer to a rectangle
|
|---|
| 342 | * text [I] pointer to the text
|
|---|
| 343 | * style [I] drawing style
|
|---|
| 344 | *
|
|---|
| 345 | * RETURNS
|
|---|
| 346 | * No return value.
|
|---|
| 347 | */
|
|---|
| 348 |
|
|---|
| 349 | VOID WINAPI
|
|---|
| 350 | DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
|
|---|
| 351 | {
|
|---|
| 352 | // ERROR DON'T KNOW HOW TO TRANSLATE!!!
|
|---|
| 353 | LPSTR p;
|
|---|
| 354 | // LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, text);
|
|---|
| 355 | DrawStatusTextA (hdc, lprc, p, style);
|
|---|
| 356 | HeapFree (GetProcessHeap (), 0, p );
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 | /***********************************************************************
|
|---|
| 361 | * CreateStatusWindow32A [COMCTL32.6][COMCTL32.21]
|
|---|
| 362 | *
|
|---|
| 363 | * Creates a status bar
|
|---|
| 364 | *
|
|---|
| 365 | * PARAMS
|
|---|
| 366 | * style [I] window style
|
|---|
| 367 | * text [I] pointer to the window text
|
|---|
| 368 | * parent [I] handle to the parent window
|
|---|
| 369 | * wid [I] control id of the status bar
|
|---|
| 370 | *
|
|---|
| 371 | * RETURNS
|
|---|
| 372 | * Success: handle to the status window
|
|---|
| 373 | * Failure: 0
|
|---|
| 374 | */
|
|---|
| 375 |
|
|---|
| 376 | HWND WINAPI
|
|---|
| 377 | CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
|
|---|
| 378 | {
|
|---|
| 379 | return CreateWindowA(STATUSCLASSNAMEA, text, style,
|
|---|
| 380 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 381 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 382 | parent, wid, 0, 0);
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 | /***********************************************************************
|
|---|
| 387 | * CreateStatusWindow32W [COMCTL32.22] Creates a status bar control
|
|---|
| 388 | *
|
|---|
| 389 | * PARAMS
|
|---|
| 390 | * style [I] window style
|
|---|
| 391 | * text [I] pointer to the window text
|
|---|
| 392 | * parent [I] handle to the parent window
|
|---|
| 393 | * wid [I] control id of the status bar
|
|---|
| 394 | *
|
|---|
| 395 | * RETURNS
|
|---|
| 396 | * Success: handle to the status window
|
|---|
| 397 | * Failure: 0
|
|---|
| 398 | */
|
|---|
| 399 |
|
|---|
| 400 | HWND WINAPI
|
|---|
| 401 | CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
|
|---|
| 402 | {
|
|---|
| 403 | return CreateWindowW(STATUSCLASSNAMEW, text, style,
|
|---|
| 404 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 405 | CW_USEDEFAULT, CW_USEDEFAULT,
|
|---|
| 406 | parent, wid, 0, 0);
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 | /***********************************************************************
|
|---|
| 411 | * CreateUpDownControl [COMCTL32.16] Creates an up-down control
|
|---|
| 412 | *
|
|---|
| 413 | * PARAMS
|
|---|
| 414 | * style [I] window styles
|
|---|
| 415 | * x [I] horizontal position of the control
|
|---|
| 416 | * y [I] vertical position of the control
|
|---|
| 417 | * cx [I] with of the control
|
|---|
| 418 | * cy [I] height of the control
|
|---|
| 419 | * parent [I] handle to the parent window
|
|---|
| 420 | * id [I] the control's identifier
|
|---|
| 421 | * inst [I] handle to the application's module instance
|
|---|
| 422 | * buddy [I] handle to the buddy window, can be NULL
|
|---|
| 423 | * maxVal [I] upper limit of the control
|
|---|
| 424 | * minVal [I] lower limit of the control
|
|---|
| 425 | * curVal [I] current value of the control
|
|---|
| 426 | *
|
|---|
| 427 | * RETURNS
|
|---|
| 428 | * Success: handle to the updown control
|
|---|
| 429 | * Failure: 0
|
|---|
| 430 | */
|
|---|
| 431 |
|
|---|
| 432 | HWND WINAPI
|
|---|
| 433 | CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
|
|---|
| 434 | HWND parent, INT id, HINSTANCE inst,
|
|---|
| 435 | HWND buddy, INT maxVal, INT minVal, INT curVal)
|
|---|
| 436 | {
|
|---|
| 437 | HWND hUD =
|
|---|
| 438 | CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
|
|---|
| 439 | parent, id, inst, 0);
|
|---|
| 440 | if (hUD) {
|
|---|
| 441 | SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
|
|---|
| 442 | SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
|
|---|
| 443 | SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | return hUD;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | /***********************************************************************
|
|---|
| 450 | * InitCommonControls [COMCTL32.17]
|
|---|
| 451 | *
|
|---|
| 452 | * Registers the common controls.
|
|---|
| 453 | *
|
|---|
| 454 | * PARAMS
|
|---|
| 455 | * No parameters.
|
|---|
| 456 | *
|
|---|
| 457 | * RETURNS
|
|---|
| 458 | * No return values.
|
|---|
| 459 | *
|
|---|
| 460 | * NOTES
|
|---|
| 461 | * This function is just a dummy.
|
|---|
| 462 | * The Win95 controls are registered at the DLL's initialization.
|
|---|
| 463 | * To register other controls InitCommonControlsEx() must be used.
|
|---|
| 464 | */
|
|---|
| 465 |
|
|---|
| 466 | VOID WINAPI InitCommonControls(VOID)
|
|---|
| 467 | {
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | /***********************************************************************
|
|---|
| 471 | * InitCommonControlsEx [COMCTL32.81]
|
|---|
| 472 | *
|
|---|
| 473 | * Registers the common controls.
|
|---|
| 474 | *
|
|---|
| 475 | * PARAMS
|
|---|
| 476 | * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
|
|---|
| 477 | *
|
|---|
| 478 | * RETURNS
|
|---|
| 479 | * Success: TRUE
|
|---|
| 480 | * Failure: FALSE
|
|---|
| 481 | *
|
|---|
| 482 | * NOTES
|
|---|
| 483 | * Only the additinal common controls are registered by this function.
|
|---|
| 484 | * The Win95 controls are registered at the DLL's initialization.
|
|---|
| 485 | */
|
|---|
| 486 |
|
|---|
| 487 | BOOL WINAPI
|
|---|
| 488 | InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
|
|---|
| 489 | {
|
|---|
| 490 | INT cCount;
|
|---|
| 491 | DWORD dwMask;
|
|---|
| 492 |
|
|---|
| 493 | if (!lpInitCtrls)
|
|---|
| 494 | return FALSE;
|
|---|
| 495 | if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
|
|---|
| 496 | return FALSE;
|
|---|
| 497 |
|
|---|
| 498 | // TRACE(commctrl,"(0x%08lx)\n", lpInitCtrls->dwICC);
|
|---|
| 499 |
|
|---|
| 500 | for (cCount = 0; cCount < 32; cCount++) {
|
|---|
| 501 | dwMask = 1 << cCount;
|
|---|
| 502 | if (!(lpInitCtrls->dwICC & dwMask))
|
|---|
| 503 | continue;
|
|---|
| 504 |
|
|---|
| 505 | switch (lpInitCtrls->dwICC & dwMask) {
|
|---|
| 506 | /* dummy initialization */
|
|---|
| 507 | case ICC_ANIMATE_CLASS:
|
|---|
| 508 | case ICC_BAR_CLASSES:
|
|---|
| 509 | case ICC_LISTVIEW_CLASSES:
|
|---|
| 510 | case ICC_TREEVIEW_CLASSES:
|
|---|
| 511 | case ICC_TAB_CLASSES:
|
|---|
| 512 | case ICC_UPDOWN_CLASS:
|
|---|
| 513 | case ICC_PROGRESS_CLASS:
|
|---|
| 514 | case ICC_HOTKEY_CLASS:
|
|---|
| 515 | break;
|
|---|
| 516 |
|
|---|
| 517 | /* advanced classes - not included in Win95 */
|
|---|
| 518 | case ICC_DATE_CLASSES:
|
|---|
| 519 | MONTHCAL_Register ();
|
|---|
| 520 | DATETIME_Register ();
|
|---|
| 521 | break;
|
|---|
| 522 |
|
|---|
| 523 | case ICC_USEREX_CLASSES:
|
|---|
| 524 | COMBOEX_Register ();
|
|---|
| 525 | break;
|
|---|
| 526 |
|
|---|
| 527 | case ICC_COOL_CLASSES:
|
|---|
| 528 | REBAR_Register ();
|
|---|
| 529 | break;
|
|---|
| 530 |
|
|---|
| 531 | case ICC_INTERNET_CLASSES:
|
|---|
| 532 | // IPADDRESS_Register ();
|
|---|
| 533 | break;
|
|---|
| 534 |
|
|---|
| 535 | case ICC_PAGESCROLLER_CLASS:
|
|---|
| 536 | PAGER_Register ();
|
|---|
| 537 | break;
|
|---|
| 538 |
|
|---|
| 539 | case ICC_NATIVEFNTCTL_CLASS:
|
|---|
| 540 | NATIVEFONT_Register ();
|
|---|
| 541 | break;
|
|---|
| 542 |
|
|---|
| 543 | default:
|
|---|
| 544 | // FIXME (commctrl, "Unknown class! dwICC=0x%lX\n", dwMask);
|
|---|
| 545 | break;
|
|---|
| 546 | }
|
|---|
| 547 | }
|
|---|
| 548 |
|
|---|
| 549 | return TRUE;
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | /***********************************************************************
|
|---|
| 553 | * CreateToolbarEx [COMCTL32.32] Creates a tool bar window
|
|---|
| 554 | *
|
|---|
| 555 | * PARAMS
|
|---|
| 556 | * hwnd
|
|---|
| 557 | * style
|
|---|
| 558 | * wID
|
|---|
| 559 | * nBitmaps
|
|---|
| 560 | * hBMInst
|
|---|
| 561 | * wBMID
|
|---|
| 562 | * lpButtons
|
|---|
| 563 | * iNumButtons
|
|---|
| 564 | * dxButton
|
|---|
| 565 | * dyButton
|
|---|
| 566 | * dxBitmap
|
|---|
| 567 | * dyBitmap
|
|---|
| 568 | * uStructSize
|
|---|
| 569 | *
|
|---|
| 570 | * RETURNS
|
|---|
| 571 | * Success: handle to the tool bar control
|
|---|
| 572 | * Failure: 0
|
|---|
| 573 | */
|
|---|
| 574 |
|
|---|
| 575 | HWND WINAPI
|
|---|
| 576 | CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
|
|---|
| 577 | HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
|
|---|
| 578 | INT iNumButtons, INT dxButton, INT dyButton,
|
|---|
| 579 | INT dxBitmap, INT dyBitmap, UINT uStructSize)
|
|---|
| 580 | {
|
|---|
| 581 | HWND hwndTB =
|
|---|
| 582 | CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style, 0, 0, 0, 0,
|
|---|
| 583 | hwnd, (HMENU)wID, 0, NULL);
|
|---|
| 584 | if(hwndTB) {
|
|---|
| 585 | TBADDBITMAP tbab;
|
|---|
| 586 |
|
|---|
| 587 | SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
|
|---|
| 588 | (WPARAM)uStructSize, 0);
|
|---|
| 589 |
|
|---|
| 590 | /* set bitmap and button size */
|
|---|
| 591 | /*If CreateToolbarEx receive 0, windows set default values*/
|
|---|
| 592 | if (dyBitmap < 0)
|
|---|
| 593 | dyBitmap = 16;
|
|---|
| 594 | if (dxBitmap < 0)
|
|---|
| 595 | dxBitmap = 16;
|
|---|
| 596 |
|
|---|
| 597 | SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
|
|---|
| 598 | MAKELPARAM((WORD)dyBitmap, (WORD)dxBitmap));
|
|---|
| 599 | SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
|
|---|
| 600 | MAKELPARAM((WORD)dyButton, (WORD)dxButton));
|
|---|
| 601 |
|
|---|
| 602 |
|
|---|
| 603 | /* add bitmaps */
|
|---|
| 604 | if (nBitmaps > 0)
|
|---|
| 605 | {
|
|---|
| 606 | tbab.hInst = hBMInst;
|
|---|
| 607 | tbab.nID = wBMID;
|
|---|
| 608 |
|
|---|
| 609 | SendMessageA (hwndTB, TB_ADDBITMAP,
|
|---|
| 610 | (WPARAM)nBitmaps, (LPARAM)&tbab);
|
|---|
| 611 | }
|
|---|
| 612 | /* add buttons */
|
|---|
| 613 | if(iNumButtons > 0)
|
|---|
| 614 | SendMessageA (hwndTB, TB_ADDBUTTONSA,
|
|---|
| 615 | (WPARAM)iNumButtons, (LPARAM)lpButtons);
|
|---|
| 616 | }
|
|---|
| 617 |
|
|---|
| 618 | return hwndTB;
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 |
|
|---|
| 622 | /***********************************************************************
|
|---|
| 623 | * CreateMappedBitmap [COMCTL32.8]
|
|---|
| 624 | *
|
|---|
| 625 | * PARAMS
|
|---|
| 626 | * hInstance [I]
|
|---|
| 627 | * idBitmap [I]
|
|---|
| 628 | * wFlags [I]
|
|---|
| 629 | * lpColorMap [I]
|
|---|
| 630 | * iNumMaps [I]
|
|---|
| 631 | *
|
|---|
| 632 | * RETURNS
|
|---|
| 633 | * Success: handle to the new bitmap
|
|---|
| 634 | * Failure: 0
|
|---|
| 635 | */
|
|---|
| 636 |
|
|---|
| 637 | HBITMAP WINAPI
|
|---|
| 638 | CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
|
|---|
| 639 | LPCOLORMAP lpColorMap, INT iNumMaps)
|
|---|
| 640 | {
|
|---|
| 641 | HGLOBAL hglb;
|
|---|
| 642 | HRSRC hRsrc;
|
|---|
| 643 | LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
|
|---|
| 644 | UINT nSize, nColorTableSize;
|
|---|
| 645 | DWORD *pColorTable;
|
|---|
| 646 | INT iColor, i, iMaps, nWidth, nHeight;
|
|---|
| 647 | HDC hdcScreen;
|
|---|
| 648 | HBITMAP hbm;
|
|---|
| 649 | LPCOLORMAP sysColorMap;
|
|---|
| 650 | COLORMAP internalColorMap[4] =
|
|---|
| 651 | {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
|
|---|
| 652 |
|
|---|
| 653 | /* initialize pointer to colortable and default color table */
|
|---|
| 654 | if (lpColorMap) {
|
|---|
| 655 | iMaps = iNumMaps;
|
|---|
| 656 | sysColorMap = lpColorMap;
|
|---|
| 657 | }
|
|---|
| 658 | else {
|
|---|
| 659 | internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
|
|---|
| 660 | internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
|
|---|
| 661 | internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
|
|---|
| 662 | internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
|
|---|
| 663 | iMaps = 4;
|
|---|
| 664 | sysColorMap = (LPCOLORMAP)internalColorMap;
|
|---|
| 665 | }
|
|---|
| 666 |
|
|---|
| 667 | hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
|
|---|
| 668 | if (hRsrc == 0)
|
|---|
| 669 | return 0;
|
|---|
| 670 | hglb = LoadResource (hInstance, hRsrc);
|
|---|
| 671 | if (hglb == 0)
|
|---|
| 672 | return 0;
|
|---|
| 673 | lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
|
|---|
| 674 | if (lpBitmap == NULL)
|
|---|
| 675 | return 0;
|
|---|
| 676 |
|
|---|
| 677 | nColorTableSize = (1 << lpBitmap->biBitCount);
|
|---|
| 678 | nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
|
|---|
| 679 | lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
|
|---|
| 680 | if (lpBitmapInfo == NULL)
|
|---|
| 681 | return 0;
|
|---|
| 682 | RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
|
|---|
| 683 |
|
|---|
| 684 | pColorTable = (DWORD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
|
|---|
| 685 |
|
|---|
| 686 | for (iColor = 0; iColor < nColorTableSize; iColor++) {
|
|---|
| 687 | for (i = 0; i < iMaps; i++) {
|
|---|
| 688 | if (pColorTable[iColor] == sysColorMap[i].from) {
|
|---|
| 689 | #if 0
|
|---|
| 690 | if (wFlags & CBS_MASKED) {
|
|---|
| 691 | if (sysColorMap[i].to != COLOR_BTNTEXT)
|
|---|
| 692 | pColorTable[iColor] = RGB(255, 255, 255);
|
|---|
| 693 | }
|
|---|
| 694 | else
|
|---|
| 695 | #endif
|
|---|
| 696 | pColorTable[iColor] = sysColorMap[i].to;
|
|---|
| 697 | break;
|
|---|
| 698 | }
|
|---|
| 699 | }
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 | nWidth = (INT)lpBitmapInfo->biWidth;
|
|---|
| 703 | nHeight = (INT)lpBitmapInfo->biHeight;
|
|---|
| 704 | hdcScreen = GetDC ((HWND)0);
|
|---|
| 705 | hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
|
|---|
| 706 | if (hbm) {
|
|---|
| 707 | HDC hdcDst = CreateCompatibleDC (hdcScreen);
|
|---|
| 708 | HBITMAP hbmOld = SelectObject (hdcDst, hbm);
|
|---|
| 709 | LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
|
|---|
| 710 | lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
|
|---|
| 711 | StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
|
|---|
| 712 | lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
|
|---|
| 713 | SRCCOPY);
|
|---|
| 714 | SelectObject (hdcDst, hbmOld);
|
|---|
| 715 | DeleteDC (hdcDst);
|
|---|
| 716 | }
|
|---|
| 717 | ReleaseDC ((HWND)0, hdcScreen);
|
|---|
| 718 | GlobalFree ((HGLOBAL)lpBitmapInfo);
|
|---|
| 719 | FreeResource (hglb);
|
|---|
| 720 |
|
|---|
| 721 | return hbm;
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 |
|
|---|
| 725 | /***********************************************************************
|
|---|
| 726 | * CreateToolbar [COMCTL32.7] Creates a tool bar control
|
|---|
| 727 | *
|
|---|
| 728 | * PARAMS
|
|---|
| 729 | * hwnd
|
|---|
| 730 | * style
|
|---|
| 731 | * wID
|
|---|
| 732 | * nBitmaps
|
|---|
| 733 | * hBMInst
|
|---|
| 734 | * wBMID
|
|---|
| 735 | * lpButtons
|
|---|
| 736 | * iNumButtons
|
|---|
| 737 | *
|
|---|
| 738 | * RETURNS
|
|---|
| 739 | * Success: handle to the tool bar control
|
|---|
| 740 | * Failure: 0
|
|---|
| 741 | *
|
|---|
| 742 | * NOTES
|
|---|
| 743 | * Do not use this functions anymore. Use CreateToolbarEx instead.
|
|---|
| 744 | */
|
|---|
| 745 |
|
|---|
| 746 | HWND WINAPI
|
|---|
| 747 | CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
|
|---|
| 748 | HINSTANCE hBMInst, UINT wBMID,
|
|---|
| 749 | LPCOLDTBBUTTON lpButtons,INT iNumButtons)
|
|---|
| 750 | {
|
|---|
| 751 | return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
|
|---|
| 752 | hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
|
|---|
| 753 | iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
|
|---|
| 754 | }
|
|---|
| 755 |
|
|---|
| 756 |
|
|---|
| 757 | /***********************************************************************
|
|---|
| 758 | * DllGetVersion [COMCTL32.25]
|
|---|
| 759 | *
|
|---|
| 760 | * Retrieves version information of the 'COMCTL32.DLL'
|
|---|
| 761 | *
|
|---|
| 762 | * PARAMS
|
|---|
| 763 | * pdvi [O] pointer to version information structure.
|
|---|
| 764 | *
|
|---|
| 765 | * RETURNS
|
|---|
| 766 | * Success: S_OK
|
|---|
| 767 | * Failure: E_INVALIDARG
|
|---|
| 768 | *
|
|---|
| 769 | * NOTES
|
|---|
| 770 | * Returns version of a comctl32.dll from IE4.01 SP1.
|
|---|
| 771 | */
|
|---|
| 772 |
|
|---|
| 773 | HRESULT WINAPI
|
|---|
| 774 | COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
|
|---|
| 775 | {
|
|---|
| 776 | if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
|
|---|
| 777 | // WARN (commctrl, "wrong DLLVERSIONINFO size from app");
|
|---|
| 778 | return E_INVALIDARG;
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | pdvi->dwMajorVersion = 4;
|
|---|
| 782 | pdvi->dwMinorVersion = 72;
|
|---|
| 783 | pdvi->dwBuildNumber = 3110;
|
|---|
| 784 | pdvi->dwPlatformID = 1;
|
|---|
| 785 |
|
|---|
| 786 | // TRACE (commctrl, "%lu.%lu.%lu.%lu\n",
|
|---|
| 787 | // pdvi->dwMajorVersion, pdvi->dwMinorVersion,
|
|---|
| 788 | // pdvi->dwBuildNumber, pdvi->dwPlatformID);
|
|---|
| 789 |
|
|---|
| 790 | return S_OK;
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|