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