| 1 | /*
 | 
|---|
| 2 |  * Common controls functions
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  * Copyright 1997 Dimitrie O. Paun
 | 
|---|
| 5 |  * Copyright 1998,2000 Eric Kohl
 | 
|---|
| 6 |  *
 | 
|---|
| 7 |  * This library is free software; you can redistribute it and/or
 | 
|---|
| 8 |  * modify it under the terms of the GNU Lesser General Public
 | 
|---|
| 9 |  * License as published by the Free Software Foundation; either
 | 
|---|
| 10 |  * version 2.1 of the License, or (at your option) any later version.
 | 
|---|
| 11 |  *
 | 
|---|
| 12 |  * This library is distributed in the hope that it will be useful,
 | 
|---|
| 13 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 14 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
|---|
| 15 |  * Lesser General Public License for more details.
 | 
|---|
| 16 |  *
 | 
|---|
| 17 |  * You should have received a copy of the GNU Lesser General Public
 | 
|---|
| 18 |  * License along with this library; if not, write to the Free Software
 | 
|---|
| 19 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|---|
| 20 |  *
 | 
|---|
| 21 |  * NOTES
 | 
|---|
| 22 |  * 
 | 
|---|
| 23 |  * This code was audited for completeness against the documented features
 | 
|---|
| 24 |  * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Christian Neumair.
 | 
|---|
| 25 |  *
 | 
|---|
| 26 |  * Unless otherwise noted, we belive this code to be complete, as per
 | 
|---|
| 27 |  * the specification mentioned above.
 | 
|---|
| 28 |  * If you discover missing features, or bugs, please note them below.
 | 
|---|
| 29 |  *
 | 
|---|
| 30 |  * TODO
 | 
|---|
| 31 |  *   -- implement GetMUILanguage + InitMUILanguage
 | 
|---|
| 32 |  *   -- LibMain => DLLMain ("DLLMain takes over the functionality of both the
 | 
|---|
| 33 |  *                           LibMain and the WEP function.", MSDN)
 | 
|---|
| 34 |  *   -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
 | 
|---|
| 35 |  *   -- FIXMEs + BUGS (search for them)
 | 
|---|
| 36 |  *
 | 
|---|
| 37 |  * Control Classes
 | 
|---|
| 38 |  *   -- ICC_ANIMATE_CLASS
 | 
|---|
| 39 |  *   -- ICC_BAR_CLASSES
 | 
|---|
| 40 |  *   -- ICC_COOL_CLASSES
 | 
|---|
| 41 |  *   -- ICC_DATE_CLASSES
 | 
|---|
| 42 |  *   -- ICC_HOTKEY_CLASS
 | 
|---|
| 43 |  *   -- ICC_INTERNET_CLASSES
 | 
|---|
| 44 |  *   -- ICC_LINK_CLASS (not yet implemented)
 | 
|---|
| 45 |  *   -- ICC_LISTVIEW_CLASSES
 | 
|---|
| 46 |  *   -- ICC_NATIVEFNTCTL_CLASS
 | 
|---|
| 47 |  *   -- ICC_PAGESCROLLER_CLASS
 | 
|---|
| 48 |  *   -- ICC_PROGRESS_CLASS
 | 
|---|
| 49 |  *   -- ICC_STANDARD_CLASSES (not yet implemented)
 | 
|---|
| 50 |  *   -- ICC_TAB_CLASSES
 | 
|---|
| 51 |  *   -- ICC_TREEVIEW_CLASSES
 | 
|---|
| 52 |  *   -- ICC_UPDOWN_CLASS
 | 
|---|
| 53 |  *   -- ICC_USEREX_CLASSES
 | 
|---|
| 54 |  *   -- ICC_WIN95_CLASSES
 | 
|---|
| 55 |  */
 | 
|---|
| 56 | 
 | 
|---|
| 57 | #include <string.h>
 | 
|---|
| 58 | #include <stdlib.h>
 | 
|---|
| 59 | 
 | 
|---|
| 60 | #include "winbase.h"
 | 
|---|
| 61 | #include "commctrl.h"
 | 
|---|
| 62 | #include "winerror.h"
 | 
|---|
| 63 | #include "winreg.h"
 | 
|---|
| 64 | #define NO_SHLWAPI_STREAM
 | 
|---|
| 65 | #include "shlwapi.h"
 | 
|---|
| 66 | #include "comctl32.h"
 | 
|---|
| 67 | #include "wine/debug.h"
 | 
|---|
| 68 | 
 | 
|---|
| 69 | WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
 | 
|---|
| 70 | 
 | 
|---|
| 71 | extern void ANIMATE_Register(void);
 | 
|---|
| 72 | extern void ANIMATE_Unregister(void);
 | 
|---|
| 73 | extern void COMBOEX_Register(void);
 | 
|---|
| 74 | extern void COMBOEX_Unregister(void);
 | 
|---|
| 75 | extern void DATETIME_Register(void);
 | 
|---|
| 76 | extern void DATETIME_Unregister(void);
 | 
|---|
| 77 | extern void FLATSB_Register(void);
 | 
|---|
| 78 | extern void FLATSB_Unregister(void);
 | 
|---|
| 79 | extern void HEADER_Register(void);
 | 
|---|
| 80 | extern void HEADER_Unregister(void);
 | 
|---|
| 81 | extern void HOTKEY_Register(void);
 | 
|---|
| 82 | extern void HOTKEY_Unregister(void);
 | 
|---|
| 83 | extern void IPADDRESS_Register(void);
 | 
|---|
| 84 | extern void IPADDRESS_Unregister(void);
 | 
|---|
| 85 | extern void LISTVIEW_Register(void);
 | 
|---|
| 86 | extern void LISTVIEW_Unregister(void);
 | 
|---|
| 87 | extern void MONTHCAL_Register(void);
 | 
|---|
| 88 | extern void MONTHCAL_Unregister(void);
 | 
|---|
| 89 | extern void NATIVEFONT_Register(void);
 | 
|---|
| 90 | extern void NATIVEFONT_Unregister(void);
 | 
|---|
| 91 | extern void PAGER_Register(void);
 | 
|---|
| 92 | extern void PAGER_Unregister(void);
 | 
|---|
| 93 | extern void PROGRESS_Register(void);
 | 
|---|
| 94 | extern void PROGRESS_Unregister(void);
 | 
|---|
| 95 | extern void REBAR_Register(void);
 | 
|---|
| 96 | extern void REBAR_Unregister(void);
 | 
|---|
| 97 | extern void STATUS_Register(void);
 | 
|---|
| 98 | extern void STATUS_Unregister(void);
 | 
|---|
| 99 | extern void TAB_Register(void);
 | 
|---|
| 100 | extern void TAB_Unregister(void);
 | 
|---|
| 101 | extern void TOOLBAR_Register(void);
 | 
|---|
| 102 | extern void TOOLBAR_Unregister(void);
 | 
|---|
| 103 | extern void TOOLTIPS_Register(void);
 | 
|---|
| 104 | extern void TOOLTIPS_Unregister(void);
 | 
|---|
| 105 | extern void TRACKBAR_Register(void);
 | 
|---|
| 106 | extern void TRACKBAR_Unregister(void);
 | 
|---|
| 107 | extern void TREEVIEW_Register(void);
 | 
|---|
| 108 | extern void TREEVIEW_Unregister(void);
 | 
|---|
| 109 | extern void UPDOWN_Register(void);
 | 
|---|
| 110 | extern void UPDOWN_Unregister(void);
 | 
|---|
| 111 | 
 | 
|---|
| 112 | 
 | 
|---|
| 113 | HANDLE COMCTL32_hHeap = NULL;
 | 
|---|
| 114 | LPSTR    COMCTL32_aSubclass = NULL;
 | 
|---|
| 115 | HMODULE COMCTL32_hModule = 0;
 | 
|---|
| 116 | LANGID  COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
 | 
|---|
| 117 | HBRUSH  COMCTL32_hPattern55AABrush = NULL;
 | 
|---|
| 118 | COMCTL32_SysColor  comctl32_color;
 | 
|---|
| 119 | 
 | 
|---|
| 120 | static HBITMAP COMCTL32_hPattern55AABitmap = NULL;
 | 
|---|
| 121 | 
 | 
|---|
| 122 | static const WORD wPattern55AA[] =
 | 
|---|
| 123 | {
 | 
|---|
| 124 |     0x5555, 0xaaaa, 0x5555, 0xaaaa,
 | 
|---|
| 125 |     0x5555, 0xaaaa, 0x5555, 0xaaaa
 | 
|---|
| 126 | };
 | 
|---|
| 127 | 
 | 
|---|
| 128 | 
 | 
|---|
| 129 | /***********************************************************************
 | 
|---|
| 130 |  * DllMain [Internal] Initializes the internal 'COMCTL32.DLL'.
 | 
|---|
| 131 |  *
 | 
|---|
| 132 |  * PARAMS
 | 
|---|
| 133 |  *     hinstDLL    [I] handle to the 'dlls' instance
 | 
|---|
| 134 |  *     fdwReason   [I]
 | 
|---|
| 135 |  *     lpvReserved [I] reserverd, must be NULL
 | 
|---|
| 136 |  *
 | 
|---|
| 137 |  * RETURNS
 | 
|---|
| 138 |  *     Success: TRUE
 | 
|---|
| 139 |  *     Failure: FALSE
 | 
|---|
| 140 |  */
 | 
|---|
| 141 | 
 | 
|---|
| 142 | #ifdef __WIN32OS2__
 | 
|---|
| 143 | BOOL WINAPI COMCTL32_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 | 
|---|
| 144 | #else
 | 
|---|
| 145 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 | 
|---|
| 146 | #endif
 | 
|---|
| 147 | {
 | 
|---|
| 148 |     TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
 | 
|---|
| 149 | 
 | 
|---|
| 150 |     switch (fdwReason) {
 | 
|---|
| 151 |         case DLL_PROCESS_ATTACH:
 | 
|---|
| 152 |             COMCTL32_hModule = (HMODULE)hinstDLL;
 | 
|---|
| 153 | 
 | 
|---|
| 154 |             /* create private heap */
 | 
|---|
| 155 |             COMCTL32_hHeap = HeapCreate (0, 0x10000, 0);
 | 
|---|
| 156 |             TRACE("Heap created: %p\n", COMCTL32_hHeap);
 | 
|---|
| 157 | 
 | 
|---|
| 158 |             /* add global subclassing atom (used by 'tooltip' and 'updown') */
 | 
|---|
| 159 |             COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
 | 
|---|
| 160 |             TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass);
 | 
|---|
| 161 | 
 | 
|---|
| 162 |             /* create local pattern brush */
 | 
|---|
| 163 |             COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA);
 | 
|---|
| 164 |             COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap);
 | 
|---|
| 165 | 
 | 
|---|
| 166 |             /* Get all the colors at DLL load */
 | 
|---|
| 167 |             COMCTL32_RefreshSysColors();
 | 
|---|
| 168 | 
 | 
|---|
| 169 |             /* register all Win95 common control classes */
 | 
|---|
| 170 |             ANIMATE_Register ();
 | 
|---|
| 171 |             FLATSB_Register ();
 | 
|---|
| 172 |             HEADER_Register ();
 | 
|---|
| 173 |             HOTKEY_Register ();
 | 
|---|
| 174 |             LISTVIEW_Register ();
 | 
|---|
| 175 |             PROGRESS_Register ();
 | 
|---|
| 176 |             STATUS_Register ();
 | 
|---|
| 177 |             TAB_Register ();
 | 
|---|
| 178 |             TOOLBAR_Register ();
 | 
|---|
| 179 |             TOOLTIPS_Register ();
 | 
|---|
| 180 |             TRACKBAR_Register ();
 | 
|---|
| 181 |             TREEVIEW_Register ();
 | 
|---|
| 182 |             UPDOWN_Register ();
 | 
|---|
| 183 |             break;
 | 
|---|
| 184 | 
 | 
|---|
| 185 |         case DLL_PROCESS_DETACH:
 | 
|---|
| 186 |             /* unregister all common control classes */
 | 
|---|
| 187 |             ANIMATE_Unregister ();
 | 
|---|
| 188 |             COMBOEX_Unregister ();
 | 
|---|
| 189 |             DATETIME_Unregister ();
 | 
|---|
| 190 |             FLATSB_Unregister ();
 | 
|---|
| 191 |             HEADER_Unregister ();
 | 
|---|
| 192 |             HOTKEY_Unregister ();
 | 
|---|
| 193 |             IPADDRESS_Unregister ();
 | 
|---|
| 194 |             LISTVIEW_Unregister ();
 | 
|---|
| 195 |             MONTHCAL_Unregister ();
 | 
|---|
| 196 |             NATIVEFONT_Unregister ();
 | 
|---|
| 197 |             PAGER_Unregister ();
 | 
|---|
| 198 |             PROGRESS_Unregister ();
 | 
|---|
| 199 |             REBAR_Unregister ();
 | 
|---|
| 200 |             STATUS_Unregister ();
 | 
|---|
| 201 |             TAB_Unregister ();
 | 
|---|
| 202 |             TOOLBAR_Unregister ();
 | 
|---|
| 203 |             TOOLTIPS_Unregister ();
 | 
|---|
| 204 |             TRACKBAR_Unregister ();
 | 
|---|
| 205 |             TREEVIEW_Unregister ();
 | 
|---|
| 206 |             UPDOWN_Unregister ();
 | 
|---|
| 207 | 
 | 
|---|
| 208 |             /* delete local pattern brush */
 | 
|---|
| 209 |             DeleteObject (COMCTL32_hPattern55AABrush);
 | 
|---|
| 210 |             COMCTL32_hPattern55AABrush = NULL;
 | 
|---|
| 211 |             DeleteObject (COMCTL32_hPattern55AABitmap);
 | 
|---|
| 212 |             COMCTL32_hPattern55AABitmap = NULL;
 | 
|---|
| 213 | 
 | 
|---|
| 214 |             /* delete global subclassing atom */
 | 
|---|
| 215 |             GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass));
 | 
|---|
| 216 |             TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass);
 | 
|---|
| 217 |             COMCTL32_aSubclass = NULL;
 | 
|---|
| 218 | 
 | 
|---|
| 219 |             /* destroy private heap */
 | 
|---|
| 220 |             HeapDestroy (COMCTL32_hHeap);
 | 
|---|
| 221 |             TRACE("Heap destroyed: %p\n", COMCTL32_hHeap);
 | 
|---|
| 222 |             COMCTL32_hHeap = NULL;
 | 
|---|
| 223 |             break;
 | 
|---|
| 224 |     }
 | 
|---|
| 225 | 
 | 
|---|
| 226 |     return TRUE;
 | 
|---|
| 227 | }
 | 
|---|
| 228 | 
 | 
|---|
| 229 | 
 | 
|---|
| 230 | /***********************************************************************
 | 
|---|
| 231 |  * MenuHelp [COMCTL32.2]
 | 
|---|
| 232 |  *
 | 
|---|
| 233 |  * PARAMS
 | 
|---|
| 234 |  *     uMsg       [I] message (WM_MENUSELECT) (see NOTES)
 | 
|---|
| 235 |  *     wParam     [I] wParam of the message uMsg
 | 
|---|
| 236 |  *     lParam     [I] lParam of the message uMsg
 | 
|---|
| 237 |  *     hMainMenu  [I] handle to the application's main menu
 | 
|---|
| 238 |  *     hInst      [I] handle to the module that contains string resources
 | 
|---|
| 239 |  *     hwndStatus [I] handle to the status bar window
 | 
|---|
| 240 |  *     lpwIDs     [I] pointer to an array of integers (see NOTES)
 | 
|---|
| 241 |  *
 | 
|---|
| 242 |  * RETURNS
 | 
|---|
| 243 |  *     No return value
 | 
|---|
| 244 |  *
 | 
|---|
| 245 |  * NOTES
 | 
|---|
| 246 |  *     The official documentation is incomplete!
 | 
|---|
| 247 |  *     This is the correct documentation:
 | 
|---|
| 248 |  *
 | 
|---|
| 249 |  *     uMsg:
 | 
|---|
| 250 |  *     MenuHelp() does NOT handle WM_COMMAND messages! It only handles
 | 
|---|
| 251 |  *     WM_MENUSELECT messages.
 | 
|---|
| 252 |  *
 | 
|---|
| 253 |  *     lpwIDs:
 | 
|---|
| 254 |  *     (will be written ...)
 | 
|---|
| 255 |  */
 | 
|---|
| 256 | 
 | 
|---|
| 257 | VOID WINAPI
 | 
|---|
| 258 | MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
 | 
|---|
| 259 |           HINSTANCE hInst, HWND hwndStatus, UINT* lpwIDs)
 | 
|---|
| 260 | {
 | 
|---|
| 261 |     UINT uMenuID = 0;
 | 
|---|
| 262 | 
 | 
|---|
| 263 |     if (!IsWindow (hwndStatus))
 | 
|---|
| 264 |         return;
 | 
|---|
| 265 | 
 | 
|---|
| 266 |     switch (uMsg) {
 | 
|---|
| 267 |         case WM_MENUSELECT:
 | 
|---|
| 268 |             TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
 | 
|---|
| 269 |                    wParam, lParam);
 | 
|---|
| 270 | 
 | 
|---|
| 271 |             if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
 | 
|---|
| 272 |                 /* menu was closed */
 | 
|---|
| 273 |                 TRACE("menu was closed!\n");
 | 
|---|
| 274 |                 SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
 | 
|---|
| 275 |             }
 | 
|---|
| 276 |             else {
 | 
|---|
| 277 |                 /* menu item was selected */
 | 
|---|
| 278 |                 if (HIWORD(wParam) & MF_POPUP)
 | 
|---|
| 279 |                     uMenuID = (UINT)*(lpwIDs+1);
 | 
|---|
| 280 |                 else
 | 
|---|
| 281 |                     uMenuID = (UINT)LOWORD(wParam);
 | 
|---|
| 282 |                 TRACE("uMenuID = %u\n", uMenuID);
 | 
|---|
| 283 | 
 | 
|---|
| 284 |                 if (uMenuID) {
 | 
|---|
| 285 |                     CHAR szText[256];
 | 
|---|
| 286 | 
 | 
|---|
| 287 |                     if (!LoadStringA (hInst, uMenuID, szText, 256))
 | 
|---|
| 288 |                         szText[0] = '\0';
 | 
|---|
| 289 | 
 | 
|---|
| 290 |                     SendMessageA (hwndStatus, SB_SETTEXTA,
 | 
|---|
| 291 |                                     255 | SBT_NOBORDERS, (LPARAM)szText);
 | 
|---|
| 292 |                     SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
 | 
|---|
| 293 |                 }
 | 
|---|
| 294 |             }
 | 
|---|
| 295 |             break;
 | 
|---|
| 296 | 
 | 
|---|
| 297 |         case WM_COMMAND :
 | 
|---|
| 298 |             TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
 | 
|---|
| 299 |                    wParam, lParam);
 | 
|---|
| 300 |             /* WM_COMMAND is not invalid since it is documented
 | 
|---|
| 301 |              * in the windows api reference. So don't output
 | 
|---|
| 302 |              * any FIXME for WM_COMMAND
 | 
|---|
| 303 |              */
 | 
|---|
| 304 |             WARN("We don't care about the WM_COMMAND\n");
 | 
|---|
| 305 |             break;
 | 
|---|
| 306 | 
 | 
|---|
| 307 |         default:
 | 
|---|
| 308 |             FIXME("Invalid Message 0x%x!\n", uMsg);
 | 
|---|
| 309 |             break;
 | 
|---|
| 310 |     }
 | 
|---|
| 311 | }
 | 
|---|
| 312 | 
 | 
|---|
| 313 | 
 | 
|---|
| 314 | /***********************************************************************
 | 
|---|
| 315 |  * ShowHideMenuCtl [COMCTL32.3]
 | 
|---|
| 316 |  *
 | 
|---|
| 317 |  * Shows or hides controls and updates the corresponding menu item.
 | 
|---|
| 318 |  *
 | 
|---|
| 319 |  * PARAMS
 | 
|---|
| 320 |  *     hwnd   [I] handle to the client window.
 | 
|---|
| 321 |  *     uFlags [I] menu command id.
 | 
|---|
| 322 |  *     lpInfo [I] pointer to an array of integers. (See NOTES.)
 | 
|---|
| 323 |  *
 | 
|---|
| 324 |  * RETURNS
 | 
|---|
| 325 |  *     Success: TRUE
 | 
|---|
| 326 |  *     Failure: FALSE
 | 
|---|
| 327 |  *
 | 
|---|
| 328 |  * NOTES
 | 
|---|
| 329 |  *     The official documentation is incomplete!
 | 
|---|
| 330 |  *     This is the correct documentation:
 | 
|---|
| 331 |  *
 | 
|---|
| 332 |  *     hwnd
 | 
|---|
| 333 |  *     Handle to the window that contains the menu and controls.
 | 
|---|
| 334 |  *
 | 
|---|
| 335 |  *     uFlags
 | 
|---|
| 336 |  *     Identifier of the menu item to receive or loose a check mark.
 | 
|---|
| 337 |  *
 | 
|---|
| 338 |  *     lpInfo
 | 
|---|
| 339 |  *     The array of integers contains pairs of values. BOTH values of
 | 
|---|
| 340 |  *     the first pair must be the handles to the application's main menu.
 | 
|---|
| 341 |  *     Each subsequent pair consists of a menu id and control id.
 | 
|---|
| 342 |  */
 | 
|---|
| 343 | 
 | 
|---|
| 344 | BOOL WINAPI
 | 
|---|
| 345 | ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
 | 
|---|
| 346 | {
 | 
|---|
| 347 |     LPINT lpMenuId;
 | 
|---|
| 348 | 
 | 
|---|
| 349 |     TRACE("%p, %x, %p\n", hwnd, uFlags, lpInfo);
 | 
|---|
| 350 | 
 | 
|---|
| 351 |     if (lpInfo == NULL)
 | 
|---|
| 352 |         return FALSE;
 | 
|---|
| 353 | 
 | 
|---|
| 354 |     if (!(lpInfo[0]) || !(lpInfo[1]))
 | 
|---|
| 355 |         return FALSE;
 | 
|---|
| 356 | 
 | 
|---|
| 357 |     /* search for control */
 | 
|---|
| 358 |     lpMenuId = &lpInfo[2];
 | 
|---|
| 359 |     while (*lpMenuId != uFlags)
 | 
|---|
| 360 |         lpMenuId += 2;
 | 
|---|
| 361 | 
 | 
|---|
| 362 |     if (GetMenuState ((HMENU)lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
 | 
|---|
| 363 |         /* uncheck menu item */
 | 
|---|
| 364 |         CheckMenuItem ((HMENU)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
 | 
|---|
| 365 | 
 | 
|---|
| 366 |         /* hide control */
 | 
|---|
| 367 |         lpMenuId++;
 | 
|---|
| 368 |         SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
 | 
|---|
| 369 |                         SWP_HIDEWINDOW);
 | 
|---|
| 370 |     }
 | 
|---|
| 371 |     else {
 | 
|---|
| 372 |         /* check menu item */
 | 
|---|
| 373 |         CheckMenuItem ((HMENU)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
 | 
|---|
| 374 | 
 | 
|---|
| 375 |         /* show control */
 | 
|---|
| 376 |         lpMenuId++;
 | 
|---|
| 377 |         SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
 | 
|---|
| 378 |                         SWP_SHOWWINDOW);
 | 
|---|
| 379 |     }
 | 
|---|
| 380 | 
 | 
|---|
| 381 |     return TRUE;
 | 
|---|
| 382 | }
 | 
|---|
| 383 | 
 | 
|---|
| 384 | 
 | 
|---|
| 385 | /***********************************************************************
 | 
|---|
| 386 |  * GetEffectiveClientRect [COMCTL32.4]
 | 
|---|
| 387 |  *
 | 
|---|
| 388 |  * PARAMS
 | 
|---|
| 389 |  *     hwnd   [I] handle to the client window.
 | 
|---|
| 390 |  *     lpRect [O] pointer to the rectangle of the client window
 | 
|---|
| 391 |  *     lpInfo [I] pointer to an array of integers (see NOTES)
 | 
|---|
| 392 |  *
 | 
|---|
| 393 |  * RETURNS
 | 
|---|
| 394 |  *     No return value.
 | 
|---|
| 395 |  *
 | 
|---|
| 396 |  * NOTES
 | 
|---|
| 397 |  *     The official documentation is incomplete!
 | 
|---|
| 398 |  *     This is the correct documentation:
 | 
|---|
| 399 |  *
 | 
|---|
| 400 |  *     lpInfo
 | 
|---|
| 401 |  *     (will be written ...)
 | 
|---|
| 402 |  */
 | 
|---|
| 403 | 
 | 
|---|
| 404 | VOID WINAPI
 | 
|---|
| 405 | GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
 | 
|---|
| 406 | {
 | 
|---|
| 407 |     RECT rcCtrl;
 | 
|---|
| 408 |     INT  *lpRun;
 | 
|---|
| 409 |     HWND hwndCtrl;
 | 
|---|
| 410 | 
 | 
|---|
| 411 |     TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
 | 
|---|
| 412 |            (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
 | 
|---|
| 413 | 
 | 
|---|
| 414 |     GetClientRect (hwnd, lpRect);
 | 
|---|
| 415 |     lpRun = lpInfo;
 | 
|---|
| 416 | 
 | 
|---|
| 417 |     do {
 | 
|---|
| 418 |         lpRun += 2;
 | 
|---|
| 419 |         if (*lpRun == 0)
 | 
|---|
| 420 |             return;
 | 
|---|
| 421 |         lpRun++;
 | 
|---|
| 422 |         hwndCtrl = GetDlgItem (hwnd, *lpRun);
 | 
|---|
| 423 |         if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
 | 
|---|
| 424 |             TRACE("control id 0x%x\n", *lpRun);
 | 
|---|
| 425 |             GetWindowRect (hwndCtrl, &rcCtrl);
 | 
|---|
| 426 |             MapWindowPoints (NULL, hwnd, (LPPOINT)&rcCtrl, 2);
 | 
|---|
| 427 |             SubtractRect (lpRect, lpRect, &rcCtrl);
 | 
|---|
| 428 |         }
 | 
|---|
| 429 |         lpRun++;
 | 
|---|
| 430 |     } while (*lpRun);
 | 
|---|
| 431 | }
 | 
|---|
| 432 | 
 | 
|---|
| 433 | 
 | 
|---|
| 434 | /***********************************************************************
 | 
|---|
| 435 |  * DrawStatusTextW [COMCTL32.@]
 | 
|---|
| 436 |  *
 | 
|---|
| 437 |  * Draws text with borders, like in a status bar.
 | 
|---|
| 438 |  *
 | 
|---|
| 439 |  * PARAMS
 | 
|---|
| 440 |  *     hdc   [I] handle to the window's display context
 | 
|---|
| 441 |  *     lprc  [I] pointer to a rectangle
 | 
|---|
| 442 |  *     text  [I] pointer to the text
 | 
|---|
| 443 |  *     style [I] drawing style
 | 
|---|
| 444 |  *
 | 
|---|
| 445 |  * RETURNS
 | 
|---|
| 446 |  *     No return value.
 | 
|---|
| 447 |  *
 | 
|---|
| 448 |  * NOTES
 | 
|---|
| 449 |  *     The style variable can have one of the following values:
 | 
|---|
| 450 |  *     (will be written ...)
 | 
|---|
| 451 |  */
 | 
|---|
| 452 | 
 | 
|---|
| 453 | void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
 | 
|---|
| 454 | {
 | 
|---|
| 455 |     RECT r = *lprc;
 | 
|---|
| 456 |     UINT border = BDR_SUNKENOUTER;
 | 
|---|
| 457 | 
 | 
|---|
| 458 |     if (style & SBT_POPOUT)
 | 
|---|
| 459 |         border = BDR_RAISEDOUTER;
 | 
|---|
| 460 |     else if (style & SBT_NOBORDERS)
 | 
|---|
| 461 |         border = 0;
 | 
|---|
| 462 | 
 | 
|---|
| 463 |     DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST);
 | 
|---|
| 464 | 
 | 
|---|
| 465 |     /* now draw text */
 | 
|---|
| 466 |     if (text) {
 | 
|---|
| 467 |         int oldbkmode = SetBkMode (hdc, TRANSPARENT);
 | 
|---|
| 468 |         UINT align = DT_LEFT;
 | 
|---|
| 469 |         if (*text == L'\t') {
 | 
|---|
| 470 |             text++;
 | 
|---|
| 471 |             align = DT_CENTER;
 | 
|---|
| 472 |             if (*text == L'\t') {
 | 
|---|
| 473 |                 text++;
 | 
|---|
| 474 |                 align = DT_RIGHT;
 | 
|---|
| 475 |             }
 | 
|---|
| 476 |         }
 | 
|---|
| 477 |         r.left += 3;
 | 
|---|
| 478 |         if (style & SBT_RTLREADING)
 | 
|---|
| 479 |             FIXME("Unsupported RTL style!\n");
 | 
|---|
| 480 |         DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
 | 
|---|
| 481 |         SetBkMode(hdc, oldbkmode);
 | 
|---|
| 482 |     }
 | 
|---|
| 483 | }
 | 
|---|
| 484 | 
 | 
|---|
| 485 | 
 | 
|---|
| 486 | /***********************************************************************
 | 
|---|
| 487 |  * DrawStatusText  [COMCTL32.@]
 | 
|---|
| 488 |  * DrawStatusTextA [COMCTL32.5]
 | 
|---|
| 489 |  *
 | 
|---|
| 490 |  * Draws text with borders, like in a status bar.
 | 
|---|
| 491 |  *
 | 
|---|
| 492 |  * PARAMS
 | 
|---|
| 493 |  *     hdc   [I] handle to the window's display context
 | 
|---|
| 494 |  *     lprc  [I] pointer to a rectangle
 | 
|---|
| 495 |  *     text  [I] pointer to the text
 | 
|---|
| 496 |  *     style [I] drawing style
 | 
|---|
| 497 |  *
 | 
|---|
| 498 |  * RETURNS
 | 
|---|
| 499 |  *     No return value.
 | 
|---|
| 500 |  */
 | 
|---|
| 501 | 
 | 
|---|
| 502 | void WINAPI DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
 | 
|---|
| 503 | {
 | 
|---|
| 504 |     INT len;
 | 
|---|
| 505 |     LPWSTR textW = NULL;
 | 
|---|
| 506 | 
 | 
|---|
| 507 |     if ( text ) {
 | 
|---|
| 508 |         if ( (len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 )) ) {
 | 
|---|
| 509 |             if ( (textW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )) )
 | 
|---|
| 510 |                 MultiByteToWideChar( CP_ACP, 0, text, -1, textW, len );
 | 
|---|
| 511 |         }
 | 
|---|
| 512 |     }
 | 
|---|
| 513 |     DrawStatusTextW( hdc, lprc, textW, style );
 | 
|---|
| 514 |     HeapFree( GetProcessHeap(), 0, textW );
 | 
|---|
| 515 | }
 | 
|---|
| 516 | 
 | 
|---|
| 517 | 
 | 
|---|
| 518 | /***********************************************************************
 | 
|---|
| 519 |  * CreateStatusWindow  [COMCTL32.@]
 | 
|---|
| 520 |  * CreateStatusWindowA [COMCTL32.6]
 | 
|---|
| 521 |  *
 | 
|---|
| 522 |  * Creates a status bar
 | 
|---|
| 523 |  *
 | 
|---|
| 524 |  * PARAMS
 | 
|---|
| 525 |  *     style  [I] window style
 | 
|---|
| 526 |  *     text   [I] pointer to the window text
 | 
|---|
| 527 |  *     parent [I] handle to the parent window
 | 
|---|
| 528 |  *     wid    [I] control id of the status bar
 | 
|---|
| 529 |  *
 | 
|---|
| 530 |  * RETURNS
 | 
|---|
| 531 |  *     Success: handle to the status window
 | 
|---|
| 532 |  *     Failure: 0
 | 
|---|
| 533 |  */
 | 
|---|
| 534 | 
 | 
|---|
| 535 | HWND WINAPI
 | 
|---|
| 536 | CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
 | 
|---|
| 537 | {
 | 
|---|
| 538 |     return CreateWindowA(STATUSCLASSNAMEA, text, style,
 | 
|---|
| 539 |                            CW_USEDEFAULT, CW_USEDEFAULT,
 | 
|---|
| 540 |                            CW_USEDEFAULT, CW_USEDEFAULT,
 | 
|---|
| 541 |                            parent, (HMENU)wid, 0, 0);
 | 
|---|
| 542 | }
 | 
|---|
| 543 | 
 | 
|---|
| 544 | 
 | 
|---|
| 545 | /***********************************************************************
 | 
|---|
| 546 |  * CreateStatusWindowW [COMCTL32.@] Creates a status bar control
 | 
|---|
| 547 |  *
 | 
|---|
| 548 |  * PARAMS
 | 
|---|
| 549 |  *     style  [I] window style
 | 
|---|
| 550 |  *     text   [I] pointer to the window text
 | 
|---|
| 551 |  *     parent [I] handle to the parent window
 | 
|---|
| 552 |  *     wid    [I] control id of the status bar
 | 
|---|
| 553 |  *
 | 
|---|
| 554 |  * RETURNS
 | 
|---|
| 555 |  *     Success: handle to the status window
 | 
|---|
| 556 |  *     Failure: 0
 | 
|---|
| 557 |  */
 | 
|---|
| 558 | 
 | 
|---|
| 559 | HWND WINAPI
 | 
|---|
| 560 | CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
 | 
|---|
| 561 | {
 | 
|---|
| 562 |     return CreateWindowW(STATUSCLASSNAMEW, text, style,
 | 
|---|
| 563 |                            CW_USEDEFAULT, CW_USEDEFAULT,
 | 
|---|
| 564 |                            CW_USEDEFAULT, CW_USEDEFAULT,
 | 
|---|
| 565 |                            parent, (HMENU)wid, 0, 0);
 | 
|---|
| 566 | }
 | 
|---|
| 567 | 
 | 
|---|
| 568 | 
 | 
|---|
| 569 | /***********************************************************************
 | 
|---|
| 570 |  * CreateUpDownControl [COMCTL32.16] Creates an up-down control
 | 
|---|
| 571 |  *
 | 
|---|
| 572 |  * PARAMS
 | 
|---|
| 573 |  *     style  [I] window styles
 | 
|---|
| 574 |  *     x      [I] horizontal position of the control
 | 
|---|
| 575 |  *     y      [I] vertical position of the control
 | 
|---|
| 576 |  *     cx     [I] with of the control
 | 
|---|
| 577 |  *     cy     [I] height of the control
 | 
|---|
| 578 |  *     parent [I] handle to the parent window
 | 
|---|
| 579 |  *     id     [I] the control's identifier
 | 
|---|
| 580 |  *     inst   [I] handle to the application's module instance
 | 
|---|
| 581 |  *     buddy  [I] handle to the buddy window, can be NULL
 | 
|---|
| 582 |  *     maxVal [I] upper limit of the control
 | 
|---|
| 583 |  *     minVal [I] lower limit of the control
 | 
|---|
| 584 |  *     curVal [I] current value of the control
 | 
|---|
| 585 |  *
 | 
|---|
| 586 |  * RETURNS
 | 
|---|
| 587 |  *     Success: handle to the updown control
 | 
|---|
| 588 |  *     Failure: 0
 | 
|---|
| 589 |  */
 | 
|---|
| 590 | 
 | 
|---|
| 591 | HWND WINAPI
 | 
|---|
| 592 | CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
 | 
|---|
| 593 |                      HWND parent, INT id, HINSTANCE inst,
 | 
|---|
| 594 |                      HWND buddy, INT maxVal, INT minVal, INT curVal)
 | 
|---|
| 595 | {
 | 
|---|
| 596 |     HWND hUD =
 | 
|---|
| 597 |         CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
 | 
|---|
| 598 |                          parent, (HMENU)id, inst, 0);
 | 
|---|
| 599 |     if (hUD) {
 | 
|---|
| 600 |         SendMessageA (hUD, UDM_SETBUDDY, (WPARAM)buddy, 0);
 | 
|---|
| 601 |         SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
 | 
|---|
| 602 |         SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
 | 
|---|
| 603 |     }
 | 
|---|
| 604 | 
 | 
|---|
| 605 |     return hUD;
 | 
|---|
| 606 | }
 | 
|---|
| 607 | 
 | 
|---|
| 608 | 
 | 
|---|
| 609 | /***********************************************************************
 | 
|---|
| 610 |  * InitCommonControls [COMCTL32.17]
 | 
|---|
| 611 |  *
 | 
|---|
| 612 |  * Registers the common controls.
 | 
|---|
| 613 |  *
 | 
|---|
| 614 |  * PARAMS
 | 
|---|
| 615 |  *     No parameters.
 | 
|---|
| 616 |  *
 | 
|---|
| 617 |  * RETURNS
 | 
|---|
| 618 |  *     No return values.
 | 
|---|
| 619 |  *
 | 
|---|
| 620 |  * NOTES
 | 
|---|
| 621 |  *     This function is just a dummy.
 | 
|---|
| 622 |  *     The Win95 controls are registered at the DLL's initialization.
 | 
|---|
| 623 |  *     To register other controls InitCommonControlsEx() must be used.
 | 
|---|
| 624 |  */
 | 
|---|
| 625 | 
 | 
|---|
| 626 | VOID WINAPI
 | 
|---|
| 627 | InitCommonControls (void)
 | 
|---|
| 628 | {
 | 
|---|
| 629 | }
 | 
|---|
| 630 | 
 | 
|---|
| 631 | 
 | 
|---|
| 632 | /***********************************************************************
 | 
|---|
| 633 |  * InitCommonControlsEx [COMCTL32.@]
 | 
|---|
| 634 |  *
 | 
|---|
| 635 |  * Registers the common controls.
 | 
|---|
| 636 |  *
 | 
|---|
| 637 |  * PARAMS
 | 
|---|
| 638 |  *     lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
 | 
|---|
| 639 |  *
 | 
|---|
| 640 |  * RETURNS
 | 
|---|
| 641 |  *     Success: TRUE
 | 
|---|
| 642 |  *     Failure: FALSE
 | 
|---|
| 643 |  *
 | 
|---|
| 644 |  * NOTES
 | 
|---|
| 645 |  *     Only the additional common controls are registered by this function.
 | 
|---|
| 646 |  *     The Win95 controls are registered at the DLL's initialization.
 | 
|---|
| 647 |  *
 | 
|---|
| 648 |  * FIXME
 | 
|---|
| 649 |  *     implement the following control classes:
 | 
|---|
| 650 |  *       ICC_LINK_CLASS
 | 
|---|
| 651 |  *       ICC_STANDARD_CLASSES
 | 
|---|
| 652 |  */
 | 
|---|
| 653 | 
 | 
|---|
| 654 | BOOL WINAPI
 | 
|---|
| 655 | InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
 | 
|---|
| 656 | {
 | 
|---|
| 657 |     INT cCount;
 | 
|---|
| 658 |     DWORD dwMask;
 | 
|---|
| 659 | 
 | 
|---|
| 660 |     if (!lpInitCtrls)
 | 
|---|
| 661 |         return FALSE;
 | 
|---|
| 662 |     if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
 | 
|---|
| 663 |         return FALSE;
 | 
|---|
| 664 | 
 | 
|---|
| 665 |     TRACE("(0x%08lx)\n", lpInitCtrls->dwICC);
 | 
|---|
| 666 | 
 | 
|---|
| 667 |     for (cCount = 0; cCount < 32; cCount++) {
 | 
|---|
| 668 |         dwMask = 1 << cCount;
 | 
|---|
| 669 |         if (!(lpInitCtrls->dwICC & dwMask))
 | 
|---|
| 670 |             continue;
 | 
|---|
| 671 | 
 | 
|---|
| 672 |         switch (lpInitCtrls->dwICC & dwMask) {
 | 
|---|
| 673 |             /* dummy initialization */
 | 
|---|
| 674 |             case ICC_ANIMATE_CLASS:
 | 
|---|
| 675 |             case ICC_BAR_CLASSES:
 | 
|---|
| 676 |             case ICC_LISTVIEW_CLASSES:
 | 
|---|
| 677 |             case ICC_TREEVIEW_CLASSES:
 | 
|---|
| 678 |             case ICC_TAB_CLASSES:
 | 
|---|
| 679 |             case ICC_UPDOWN_CLASS:
 | 
|---|
| 680 |             case ICC_PROGRESS_CLASS:
 | 
|---|
| 681 |             case ICC_HOTKEY_CLASS:
 | 
|---|
| 682 |                 break;
 | 
|---|
| 683 | 
 | 
|---|
| 684 |             /* advanced classes - not included in Win95 */
 | 
|---|
| 685 |             case ICC_DATE_CLASSES:
 | 
|---|
| 686 |                 MONTHCAL_Register ();
 | 
|---|
| 687 |                 DATETIME_Register ();
 | 
|---|
| 688 |                 break;
 | 
|---|
| 689 | 
 | 
|---|
| 690 |             case ICC_USEREX_CLASSES:
 | 
|---|
| 691 |                 COMBOEX_Register ();
 | 
|---|
| 692 |                 break;
 | 
|---|
| 693 | 
 | 
|---|
| 694 |             case ICC_COOL_CLASSES:
 | 
|---|
| 695 |                 REBAR_Register ();
 | 
|---|
| 696 |                 break;
 | 
|---|
| 697 | 
 | 
|---|
| 698 |             case ICC_INTERNET_CLASSES:
 | 
|---|
| 699 |                 IPADDRESS_Register ();
 | 
|---|
| 700 |                 break;
 | 
|---|
| 701 | 
 | 
|---|
| 702 |             case ICC_PAGESCROLLER_CLASS:
 | 
|---|
| 703 |                 PAGER_Register ();
 | 
|---|
| 704 |                 break;
 | 
|---|
| 705 | 
 | 
|---|
| 706 |             case ICC_NATIVEFNTCTL_CLASS:
 | 
|---|
| 707 |                 NATIVEFONT_Register ();
 | 
|---|
| 708 |                 break;
 | 
|---|
| 709 | 
 | 
|---|
| 710 |             default:
 | 
|---|
| 711 |                 FIXME("Unknown class! dwICC=0x%lX\n", dwMask);
 | 
|---|
| 712 |                 break;
 | 
|---|
| 713 |         }
 | 
|---|
| 714 |     }
 | 
|---|
| 715 | 
 | 
|---|
| 716 |     return TRUE;
 | 
|---|
| 717 | }
 | 
|---|
| 718 | 
 | 
|---|
| 719 | 
 | 
|---|
| 720 | /***********************************************************************
 | 
|---|
| 721 |  * CreateToolbarEx [COMCTL32.@] Creates a tool bar window
 | 
|---|
| 722 |  *
 | 
|---|
| 723 |  * PARAMS
 | 
|---|
| 724 |  *     hwnd
 | 
|---|
| 725 |  *     style
 | 
|---|
| 726 |  *     wID
 | 
|---|
| 727 |  *     nBitmaps
 | 
|---|
| 728 |  *     hBMInst
 | 
|---|
| 729 |  *     wBMID
 | 
|---|
| 730 |  *     lpButtons
 | 
|---|
| 731 |  *     iNumButtons
 | 
|---|
| 732 |  *     dxButton
 | 
|---|
| 733 |  *     dyButton
 | 
|---|
| 734 |  *     dxBitmap
 | 
|---|
| 735 |  *     dyBitmap
 | 
|---|
| 736 |  *     uStructSize
 | 
|---|
| 737 |  *
 | 
|---|
| 738 |  * RETURNS
 | 
|---|
| 739 |  *     Success: handle to the tool bar control
 | 
|---|
| 740 |  *     Failure: 0
 | 
|---|
| 741 |  */
 | 
|---|
| 742 | 
 | 
|---|
| 743 | HWND WINAPI
 | 
|---|
| 744 | CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
 | 
|---|
| 745 |                  HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
 | 
|---|
| 746 |                  INT iNumButtons, INT dxButton, INT dyButton,
 | 
|---|
| 747 |                  INT dxBitmap, INT dyBitmap, UINT uStructSize)
 | 
|---|
| 748 | {
 | 
|---|
| 749 |     HWND hwndTB;
 | 
|---|
| 750 | 
 | 
|---|
| 751 |     /* If not position is specified then put it at the top */
 | 
|---|
| 752 |     if ((style & CCS_BOTTOM) == 0) {
 | 
|---|
| 753 |       style|=CCS_TOP;
 | 
|---|
| 754 |     }
 | 
|---|
| 755 | 
 | 
|---|
| 756 |     hwndTB =
 | 
|---|
| 757 |         CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style|WS_CHILD, 0, 0, 0, 0,
 | 
|---|
| 758 |                            hwnd, (HMENU)wID, 0, NULL);
 | 
|---|
| 759 |     if(hwndTB) {
 | 
|---|
| 760 |         TBADDBITMAP tbab;
 | 
|---|
| 761 | 
 | 
|---|
| 762 |         SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
 | 
|---|
| 763 |                         (WPARAM)uStructSize, 0);
 | 
|---|
| 764 | 
 | 
|---|
| 765 |        /* set bitmap and button size */
 | 
|---|
| 766 |        /*If CreateToolbarEx receives 0, windows sets default values*/
 | 
|---|
| 767 |        if (dxBitmap <= 0)
 | 
|---|
| 768 |            dxBitmap = 16;
 | 
|---|
| 769 |        if (dyBitmap <= 0)
 | 
|---|
| 770 |            dyBitmap = 15;
 | 
|---|
| 771 |        SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
 | 
|---|
| 772 |                        MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
 | 
|---|
| 773 | 
 | 
|---|
| 774 |        if (dxButton <= 0)
 | 
|---|
| 775 |            dxButton = 24;
 | 
|---|
| 776 |        if (dyButton <= 0)
 | 
|---|
| 777 |            dyButton = 22;
 | 
|---|
| 778 |        SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
 | 
|---|
| 779 |                        MAKELPARAM((WORD)dxButton, (WORD)dyButton));
 | 
|---|
| 780 | 
 | 
|---|
| 781 | 
 | 
|---|
| 782 |         /* add bitmaps */
 | 
|---|
| 783 |         if (nBitmaps > 0)
 | 
|---|
| 784 |         {
 | 
|---|
| 785 |         tbab.hInst = hBMInst;
 | 
|---|
| 786 |         tbab.nID   = wBMID;
 | 
|---|
| 787 | 
 | 
|---|
| 788 |         SendMessageA (hwndTB, TB_ADDBITMAP,
 | 
|---|
| 789 |                         (WPARAM)nBitmaps, (LPARAM)&tbab);
 | 
|---|
| 790 |         }
 | 
|---|
| 791 |         /* add buttons */
 | 
|---|
| 792 |         if(iNumButtons > 0)
 | 
|---|
| 793 |         SendMessageA (hwndTB, TB_ADDBUTTONSA,
 | 
|---|
| 794 |                         (WPARAM)iNumButtons, (LPARAM)lpButtons);
 | 
|---|
| 795 |     }
 | 
|---|
| 796 | 
 | 
|---|
| 797 |     return hwndTB;
 | 
|---|
| 798 | }
 | 
|---|
| 799 | 
 | 
|---|
| 800 | 
 | 
|---|
| 801 | /***********************************************************************
 | 
|---|
| 802 |  * CreateMappedBitmap [COMCTL32.8]
 | 
|---|
| 803 |  *
 | 
|---|
| 804 |  * PARAMS
 | 
|---|
| 805 |  *     hInstance  [I]
 | 
|---|
| 806 |  *     idBitmap   [I]
 | 
|---|
| 807 |  *     wFlags     [I]
 | 
|---|
| 808 |  *     lpColorMap [I]
 | 
|---|
| 809 |  *     iNumMaps   [I]
 | 
|---|
| 810 |  *
 | 
|---|
| 811 |  * RETURNS
 | 
|---|
| 812 |  *     Success: handle to the new bitmap
 | 
|---|
| 813 |  *     Failure: 0
 | 
|---|
| 814 |  */
 | 
|---|
| 815 | 
 | 
|---|
| 816 | HBITMAP WINAPI
 | 
|---|
| 817 | CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
 | 
|---|
| 818 |                     LPCOLORMAP lpColorMap, INT iNumMaps)
 | 
|---|
| 819 | {
 | 
|---|
| 820 |     HGLOBAL hglb;
 | 
|---|
| 821 |     HRSRC hRsrc;
 | 
|---|
| 822 |     LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
 | 
|---|
| 823 |     UINT nSize, nColorTableSize;
 | 
|---|
| 824 |     RGBQUAD *pColorTable;
 | 
|---|
| 825 |     INT iColor, i, iMaps, nWidth, nHeight;
 | 
|---|
| 826 |     HDC hdcScreen;
 | 
|---|
| 827 |     HBITMAP hbm;
 | 
|---|
| 828 |     LPCOLORMAP sysColorMap;
 | 
|---|
| 829 |     COLORREF cRef;
 | 
|---|
| 830 |     COLORMAP internalColorMap[4] =
 | 
|---|
| 831 |         {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
 | 
|---|
| 832 | 
 | 
|---|
| 833 |     /* initialize pointer to colortable and default color table */
 | 
|---|
| 834 |     if (lpColorMap) {
 | 
|---|
| 835 |         iMaps = iNumMaps;
 | 
|---|
| 836 |         sysColorMap = lpColorMap;
 | 
|---|
| 837 |     }
 | 
|---|
| 838 |     else {
 | 
|---|
| 839 |         internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
 | 
|---|
| 840 |         internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
 | 
|---|
| 841 |         internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
 | 
|---|
| 842 |         internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
 | 
|---|
| 843 |         iMaps = 4;
 | 
|---|
| 844 |         sysColorMap = (LPCOLORMAP)internalColorMap;
 | 
|---|
| 845 |     }
 | 
|---|
| 846 | 
 | 
|---|
| 847 |     hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
 | 
|---|
| 848 |     if (hRsrc == 0)
 | 
|---|
| 849 |         return 0;
 | 
|---|
| 850 |     hglb = LoadResource (hInstance, hRsrc);
 | 
|---|
| 851 |     if (hglb == 0)
 | 
|---|
| 852 |         return 0;
 | 
|---|
| 853 |     lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
 | 
|---|
| 854 |     if (lpBitmap == NULL)
 | 
|---|
| 855 |         return 0;
 | 
|---|
| 856 | 
 | 
|---|
| 857 |     nColorTableSize = (1 << lpBitmap->biBitCount);
 | 
|---|
| 858 |     nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
 | 
|---|
| 859 |     lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
 | 
|---|
| 860 |     if (lpBitmapInfo == NULL)
 | 
|---|
| 861 |         return 0;
 | 
|---|
| 862 |     RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
 | 
|---|
| 863 | 
 | 
|---|
| 864 |     pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
 | 
|---|
| 865 | 
 | 
|---|
| 866 |     for (iColor = 0; iColor < nColorTableSize; iColor++) {
 | 
|---|
| 867 |         for (i = 0; i < iMaps; i++) {
 | 
|---|
| 868 |             cRef = RGB(pColorTable[iColor].rgbRed,
 | 
|---|
| 869 |                        pColorTable[iColor].rgbGreen,
 | 
|---|
| 870 |                        pColorTable[iColor].rgbBlue);
 | 
|---|
| 871 |             if ( cRef  == sysColorMap[i].from) {
 | 
|---|
| 872 | #if 0
 | 
|---|
| 873 |                 if (wFlags & CBS_MASKED) {
 | 
|---|
| 874 |                     if (sysColorMap[i].to != COLOR_BTNTEXT)
 | 
|---|
| 875 |                         pColorTable[iColor] = RGB(255, 255, 255);
 | 
|---|
| 876 |                 }
 | 
|---|
| 877 |                 else
 | 
|---|
| 878 | #endif
 | 
|---|
| 879 |                     pColorTable[iColor].rgbBlue  = GetBValue(sysColorMap[i].to);
 | 
|---|
| 880 |                     pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
 | 
|---|
| 881 |                     pColorTable[iColor].rgbRed   = GetRValue(sysColorMap[i].to);
 | 
|---|
| 882 |                 break;
 | 
|---|
| 883 |             }
 | 
|---|
| 884 |         }
 | 
|---|
| 885 |     }
 | 
|---|
| 886 |     nWidth  = (INT)lpBitmapInfo->biWidth;
 | 
|---|
| 887 |     nHeight = (INT)lpBitmapInfo->biHeight;
 | 
|---|
| 888 |     hdcScreen = GetDC (NULL);
 | 
|---|
| 889 |     hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
 | 
|---|
| 890 |     if (hbm) {
 | 
|---|
| 891 |         HDC hdcDst = CreateCompatibleDC (hdcScreen);
 | 
|---|
| 892 |         HBITMAP hbmOld = SelectObject (hdcDst, hbm);
 | 
|---|
| 893 |         LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
 | 
|---|
| 894 |         lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
 | 
|---|
| 895 |         StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
 | 
|---|
| 896 |                          lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
 | 
|---|
| 897 |                          SRCCOPY);
 | 
|---|
| 898 |         SelectObject (hdcDst, hbmOld);
 | 
|---|
| 899 |         DeleteDC (hdcDst);
 | 
|---|
| 900 |     }
 | 
|---|
| 901 |     ReleaseDC (NULL, hdcScreen);
 | 
|---|
| 902 |     GlobalFree ((HGLOBAL)lpBitmapInfo);
 | 
|---|
| 903 |     FreeResource (hglb);
 | 
|---|
| 904 | 
 | 
|---|
| 905 |     return hbm;
 | 
|---|
| 906 | }
 | 
|---|
| 907 | 
 | 
|---|
| 908 | 
 | 
|---|
| 909 | /***********************************************************************
 | 
|---|
| 910 |  * CreateToolbar [COMCTL32.7] Creates a tool bar control
 | 
|---|
| 911 |  *
 | 
|---|
| 912 |  * PARAMS
 | 
|---|
| 913 |  *     hwnd
 | 
|---|
| 914 |  *     style
 | 
|---|
| 915 |  *     wID
 | 
|---|
| 916 |  *     nBitmaps
 | 
|---|
| 917 |  *     hBMInst
 | 
|---|
| 918 |  *     wBMID
 | 
|---|
| 919 |  *     lpButtons
 | 
|---|
| 920 |  *     iNumButtons
 | 
|---|
| 921 |  *
 | 
|---|
| 922 |  * RETURNS
 | 
|---|
| 923 |  *     Success: handle to the tool bar control
 | 
|---|
| 924 |  *     Failure: 0
 | 
|---|
| 925 |  *
 | 
|---|
| 926 |  * NOTES
 | 
|---|
| 927 |  *     Do not use this functions anymore. Use CreateToolbarEx instead.
 | 
|---|
| 928 |  */
 | 
|---|
| 929 | 
 | 
|---|
| 930 | HWND WINAPI
 | 
|---|
| 931 | CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
 | 
|---|
| 932 |                HINSTANCE hBMInst, UINT wBMID,
 | 
|---|
| 933 |                LPCOLDTBBUTTON lpButtons,INT iNumButtons)
 | 
|---|
| 934 | {
 | 
|---|
| 935 |     return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
 | 
|---|
| 936 |                             hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
 | 
|---|
| 937 |                             iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
 | 
|---|
| 938 | }
 | 
|---|
| 939 | 
 | 
|---|
| 940 | 
 | 
|---|
| 941 | /***********************************************************************
 | 
|---|
| 942 |  * DllGetVersion [COMCTL32.@]
 | 
|---|
| 943 |  *
 | 
|---|
| 944 |  * Retrieves version information of the 'COMCTL32.DLL'
 | 
|---|
| 945 |  *
 | 
|---|
| 946 |  * PARAMS
 | 
|---|
| 947 |  *     pdvi [O] pointer to version information structure.
 | 
|---|
| 948 |  *
 | 
|---|
| 949 |  * RETURNS
 | 
|---|
| 950 |  *     Success: S_OK
 | 
|---|
| 951 |  *     Failure: E_INVALIDARG
 | 
|---|
| 952 |  *
 | 
|---|
| 953 |  * NOTES
 | 
|---|
| 954 |  *     Returns version of a comctl32.dll from IE4.01 SP1.
 | 
|---|
| 955 |  */
 | 
|---|
| 956 | 
 | 
|---|
| 957 | HRESULT WINAPI
 | 
|---|
| 958 | COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
 | 
|---|
| 959 | {
 | 
|---|
| 960 |     if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
 | 
|---|
| 961 |         WARN("wrong DLLVERSIONINFO size from app\n");
 | 
|---|
| 962 |         return E_INVALIDARG;
 | 
|---|
| 963 |     }
 | 
|---|
| 964 | 
 | 
|---|
| 965 |     pdvi->dwMajorVersion = COMCTL32_VERSION;
 | 
|---|
| 966 |     pdvi->dwMinorVersion = COMCTL32_VERSION_MINOR;
 | 
|---|
| 967 |     pdvi->dwBuildNumber = 2919;
 | 
|---|
| 968 |     pdvi->dwPlatformID = 6304;
 | 
|---|
| 969 | 
 | 
|---|
| 970 |     TRACE("%lu.%lu.%lu.%lu\n",
 | 
|---|
| 971 |            pdvi->dwMajorVersion, pdvi->dwMinorVersion,
 | 
|---|
| 972 |            pdvi->dwBuildNumber, pdvi->dwPlatformID);
 | 
|---|
| 973 | 
 | 
|---|
| 974 |     return S_OK;
 | 
|---|
| 975 | }
 | 
|---|
| 976 | 
 | 
|---|
| 977 | /***********************************************************************
 | 
|---|
| 978 |  *              DllInstall (COMCTL32.@)
 | 
|---|
| 979 |  */
 | 
|---|
| 980 | HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
 | 
|---|
| 981 | {
 | 
|---|
| 982 |   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
 | 
|---|
| 983 |         debugstr_w(cmdline));
 | 
|---|
| 984 | 
 | 
|---|
| 985 |   return S_OK;
 | 
|---|
| 986 | }
 | 
|---|
| 987 | 
 | 
|---|
| 988 | /***********************************************************************
 | 
|---|
| 989 |  * _TrackMouseEvent [COMCTL32.@]
 | 
|---|
| 990 |  *
 | 
|---|
| 991 |  * Requests notification of mouse events
 | 
|---|
| 992 |  *
 | 
|---|
| 993 |  * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
 | 
|---|
| 994 |  * to the hwnd specified in the ptme structure.  After the event message
 | 
|---|
| 995 |  * is posted to the hwnd, the entry in the queue is removed.
 | 
|---|
| 996 |  *
 | 
|---|
| 997 |  * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
 | 
|---|
| 998 |  * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
 | 
|---|
| 999 |  * immediately and the TME_LEAVE flag being ignored.
 | 
|---|
| 1000 |  *
 | 
|---|
| 1001 |  * PARAMS
 | 
|---|
| 1002 |  *     ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
 | 
|---|
| 1003 |  *
 | 
|---|
| 1004 |  * RETURNS
 | 
|---|
| 1005 |  *     Success: non-zero
 | 
|---|
| 1006 |  *     Failure: zero
 | 
|---|
| 1007 |  *
 | 
|---|
| 1008 |  * IMPLEMENTATION moved to USER32.TrackMouseEvent
 | 
|---|
| 1009 |  *
 | 
|---|
| 1010 |  */
 | 
|---|
| 1011 | 
 | 
|---|
| 1012 | BOOL WINAPI
 | 
|---|
| 1013 | _TrackMouseEvent (TRACKMOUSEEVENT *ptme)
 | 
|---|
| 1014 | {
 | 
|---|
| 1015 |     return TrackMouseEvent (ptme);
 | 
|---|
| 1016 | }
 | 
|---|
| 1017 | 
 | 
|---|
| 1018 | /*************************************************************************
 | 
|---|
| 1019 |  * GetMUILanguage [COMCTL32.@]
 | 
|---|
| 1020 |  *
 | 
|---|
| 1021 |  * FIXME: "Returns the language currently in use by the common controls
 | 
|---|
| 1022 |  * for a particular process." (MSDN)
 | 
|---|
| 1023 |  *
 | 
|---|
| 1024 |  */
 | 
|---|
| 1025 | LANGID WINAPI GetMUILanguage (VOID)
 | 
|---|
| 1026 | {
 | 
|---|
| 1027 |     return COMCTL32_uiLang;
 | 
|---|
| 1028 | }
 | 
|---|
| 1029 | 
 | 
|---|
| 1030 | 
 | 
|---|
| 1031 | /*************************************************************************
 | 
|---|
| 1032 |  * InitMUILanguage [COMCTL32.@]
 | 
|---|
| 1033 |  *
 | 
|---|
| 1034 |  * FIXME: "Enables an application to specify a language to be used with
 | 
|---|
| 1035 |  * the common controls that is different than the system language." (MSDN)
 | 
|---|
| 1036 |  *
 | 
|---|
| 1037 |  */
 | 
|---|
| 1038 | 
 | 
|---|
| 1039 | VOID WINAPI InitMUILanguage (LANGID uiLang)
 | 
|---|
| 1040 | {
 | 
|---|
| 1041 |    COMCTL32_uiLang = uiLang;
 | 
|---|
| 1042 | }
 | 
|---|
| 1043 | 
 | 
|---|
| 1044 | 
 | 
|---|
| 1045 | /***********************************************************************
 | 
|---|
| 1046 |  * SetWindowSubclass [COMCTL32.410]
 | 
|---|
| 1047 |  *
 | 
|---|
| 1048 |  * Starts a window subclass
 | 
|---|
| 1049 |  *
 | 
|---|
| 1050 |  * PARAMS
 | 
|---|
| 1051 |  *     hWnd [in] handle to window subclass.
 | 
|---|
| 1052 |  *     pfnSubclass [in] Pointer to new window procedure.
 | 
|---|
| 1053 |  *     uIDSubclass [in] Unique identifier of sublass together with pfnSubclass.
 | 
|---|
| 1054 |  *     dwRef [in] Reference data to pass to window procedure.
 | 
|---|
| 1055 |  *
 | 
|---|
| 1056 |  * RETURNS
 | 
|---|
| 1057 |  *     Success: non-zero
 | 
|---|
| 1058 |  *     Failure: zero
 | 
|---|
| 1059 |  *
 | 
|---|
| 1060 |  * BUGS
 | 
|---|
| 1061 |  *     If an application manually subclasses a window after subclassing it with
 | 
|---|
| 1062 |  *     this API and then with this API again, then none of the previous 
 | 
|---|
| 1063 |  *     subclasses get called or the origional window procedure.
 | 
|---|
| 1064 |  */
 | 
|---|
| 1065 | 
 | 
|---|
| 1066 | BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
 | 
|---|
| 1067 |                         UINT_PTR uIDSubclass, DWORD_PTR dwRef)
 | 
|---|
| 1068 | {
 | 
|---|
| 1069 |    LPSUBCLASS_INFO stack;
 | 
|---|
| 1070 |    int newnum, n;
 | 
|---|
| 1071 | 
 | 
|---|
| 1072 |    TRACE ("(%p, %p, %x, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
 | 
|---|
| 1073 | 
 | 
|---|
| 1074 |    /* Since the window procedure that we set here has two additional arguments,
 | 
|---|
| 1075 |     * we can't simply set it as the new window procedure of the window. So we
 | 
|---|
| 1076 |     * set our own window procedure and then calculate the other two arguments
 | 
|---|
| 1077 |     * from there. */
 | 
|---|
| 1078 | 
 | 
|---|
| 1079 |    /* See if we have been called for this window */
 | 
|---|
| 1080 |    stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
 | 
|---|
| 1081 |    if (!stack) {
 | 
|---|
| 1082 |       /* allocate stack */
 | 
|---|
| 1083 |       stack = (LPSUBCLASS_INFO)HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY,
 | 
|---|
| 1084 |                                          sizeof(SUBCLASS_INFO));
 | 
|---|
| 1085 |       if (!stack) {
 | 
|---|
| 1086 |          ERR ("Failed to allocate our Subclassing stack");
 | 
|---|
| 1087 |          return FALSE;
 | 
|---|
| 1088 |       }
 | 
|---|
| 1089 |       SetPropA (hWnd, COMCTL32_aSubclass, (HANDLE)stack);
 | 
|---|
| 1090 | 
 | 
|---|
| 1091 |       /* set window procedure to our own and save the current one */
 | 
|---|
| 1092 |       if (IsWindowUnicode (hWnd))
 | 
|---|
| 1093 |          stack->origproc = (WNDPROC)SetWindowLongW (hWnd, GWL_WNDPROC,
 | 
|---|
| 1094 |                                                    (LONG)DefSubclassProc);
 | 
|---|
| 1095 |       else
 | 
|---|
| 1096 |          stack->origproc = (WNDPROC)SetWindowLongA (hWnd, GWL_WNDPROC,
 | 
|---|
| 1097 |                                                    (LONG)DefSubclassProc);
 | 
|---|
| 1098 |    } else {
 | 
|---|
| 1099 |       WNDPROC current;
 | 
|---|
| 1100 |       if (IsWindowUnicode (hWnd))
 | 
|---|
| 1101 |          current = (WNDPROC)GetWindowLongW (hWnd, GWL_WNDPROC);
 | 
|---|
| 1102 |       else
 | 
|---|
| 1103 |          current = (WNDPROC)GetWindowLongA (hWnd, GWL_WNDPROC);
 | 
|---|
| 1104 | 
 | 
|---|
| 1105 |       if (current != DefSubclassProc) {
 | 
|---|
| 1106 |          ERR ("Application has subclassed with our procedure, then manually, then with us again.  The current implementation can't handle this.\n");
 | 
|---|
| 1107 |          return FALSE;
 | 
|---|
| 1108 |       }
 | 
|---|
| 1109 |    }
 | 
|---|
| 1110 | 
 | 
|---|
| 1111 |    /* Check to see if we have called this function with the same uIDSubClass
 | 
|---|
| 1112 |     * and pfnSubclass */
 | 
|---|
| 1113 |    for (n = 0; n <= stack->stacknum + stack->stacknew - 1; n++)
 | 
|---|
| 1114 |       if ((stack->SubclassProcs[n].id == uIDSubclass) && 
 | 
|---|
| 1115 |          (stack->SubclassProcs[n].subproc == pfnSubclass)) {
 | 
|---|
| 1116 |          stack->SubclassProcs[n].ref = dwRef;
 | 
|---|
| 1117 |          return TRUE;
 | 
|---|
| 1118 |       }
 | 
|---|
| 1119 | 
 | 
|---|
| 1120 |    if ((stack->stacknum + stack->stacknew) >= 32) {
 | 
|---|
| 1121 |       ERR ("We have a Subclass stack overflow, please increment size");
 | 
|---|
| 1122 |       return FALSE;
 | 
|---|
| 1123 |    }
 | 
|---|
| 1124 | 
 | 
|---|
| 1125 |    /* we can't simply increment both stackpos and stacknum because there might
 | 
|---|
| 1126 |     * be a window procedure running lower in the stack, we can only get them
 | 
|---|
| 1127 |     * up to date once the last window procedure has run */
 | 
|---|
| 1128 |    if (stack->stacknum == stack->stackpos) {
 | 
|---|
| 1129 |       stack->stacknum++;
 | 
|---|
| 1130 |       stack->stackpos++;
 | 
|---|
| 1131 |    } else
 | 
|---|
| 1132 |       stack->stacknew++;
 | 
|---|
| 1133 | 
 | 
|---|
| 1134 |    newnum = stack->stacknew + stack->stacknum - 1;
 | 
|---|
| 1135 | 
 | 
|---|
| 1136 |    stack->SubclassProcs[newnum].subproc = pfnSubclass;
 | 
|---|
| 1137 |    stack->SubclassProcs[newnum].ref = dwRef;
 | 
|---|
| 1138 |    stack->SubclassProcs[newnum].id = uIDSubclass;
 | 
|---|
| 1139 |    
 | 
|---|
| 1140 |    return TRUE;
 | 
|---|
| 1141 | }
 | 
|---|
| 1142 | 
 | 
|---|
| 1143 | 
 | 
|---|
| 1144 | /***********************************************************************
 | 
|---|
| 1145 |  * GetWindowSubclass [COMCTL32.411]
 | 
|---|
| 1146 |  *
 | 
|---|
| 1147 |  * Gets the Reference data from a subclass.
 | 
|---|
| 1148 |  *
 | 
|---|
| 1149 |  * PARAMS
 | 
|---|
| 1150 |  *     hWnd [in] Handle to window which were subclassing
 | 
|---|
| 1151 |  *     pfnSubclass [in] Pointer to the subclass procedure
 | 
|---|
| 1152 |  *     uID [in] Unique indentifier of the subclassing procedure
 | 
|---|
| 1153 |  *     pdwRef [out] Pointer to the reference data
 | 
|---|
| 1154 |  *
 | 
|---|
| 1155 |  * RETURNS
 | 
|---|
| 1156 |  *     Success: Non-zero
 | 
|---|
| 1157 |  *     Failure: 0
 | 
|---|
| 1158 |  */
 | 
|---|
| 1159 | 
 | 
|---|
| 1160 | BOOL WINAPI GetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
 | 
|---|
| 1161 |                               UINT_PTR uID, DWORD_PTR *pdwRef)
 | 
|---|
| 1162 | {
 | 
|---|
| 1163 |    LPSUBCLASS_INFO stack;
 | 
|---|
| 1164 |    int n;
 | 
|---|
| 1165 | 
 | 
|---|
| 1166 |    TRACE ("(%p, %p, %x, %p)\n", hWnd, pfnSubclass, uID, pdwRef);
 | 
|---|
| 1167 | 
 | 
|---|
| 1168 |    /* See if we have been called for this window */
 | 
|---|
| 1169 |    stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
 | 
|---|
| 1170 |    if (!stack)
 | 
|---|
| 1171 |       return FALSE;
 | 
|---|
| 1172 | 
 | 
|---|
| 1173 |    for (n = 0; n <= stack->stacknum + stack->stacknew - 1; n++)
 | 
|---|
| 1174 |       if ((stack->SubclassProcs[n].id == uID) &&
 | 
|---|
| 1175 |          (stack->SubclassProcs[n].subproc == pfnSubclass)) {
 | 
|---|
| 1176 |          *pdwRef = stack->SubclassProcs[n].ref;
 | 
|---|
| 1177 |          return TRUE;
 | 
|---|
| 1178 |       }
 | 
|---|
| 1179 | 
 | 
|---|
| 1180 |    return FALSE;
 | 
|---|
| 1181 | }
 | 
|---|
| 1182 | 
 | 
|---|
| 1183 | 
 | 
|---|
| 1184 | /***********************************************************************
 | 
|---|
| 1185 |  * RemoveWindowSubclass [COMCTL32.412]
 | 
|---|
| 1186 |  *
 | 
|---|
| 1187 |  * Removes a window subclass.
 | 
|---|
| 1188 |  *
 | 
|---|
| 1189 |  * PARAMS
 | 
|---|
| 1190 |  *     hWnd [in] Handle to the window were subclassing
 | 
|---|
| 1191 |  *     pfnSubclass [in] Pointer to the subclass procedure
 | 
|---|
| 1192 |  *     uID [in] Unique identifier of this subclass
 | 
|---|
| 1193 |  *
 | 
|---|
| 1194 |  * RETURNS
 | 
|---|
| 1195 |  *     Success: non-zero
 | 
|---|
| 1196 |  *     Failure: zero
 | 
|---|
| 1197 |  */
 | 
|---|
| 1198 | 
 | 
|---|
| 1199 | BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
 | 
|---|
| 1200 | {
 | 
|---|
| 1201 |    LPSUBCLASS_INFO stack;
 | 
|---|
| 1202 |    int n;
 | 
|---|
| 1203 | 
 | 
|---|
| 1204 |    TRACE ("(%p, %p, %x)\n", hWnd, pfnSubclass, uID);
 | 
|---|
| 1205 | 
 | 
|---|
| 1206 |    /* Find the Subclass to remove */
 | 
|---|
| 1207 |    stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
 | 
|---|
| 1208 |    if (!stack)
 | 
|---|
| 1209 |       return FALSE;
 | 
|---|
| 1210 | 
 | 
|---|
| 1211 |    if ((stack->stacknum == stack->stackpos == 1) && !stack->stacknew) {
 | 
|---|
| 1212 |       TRACE("Last Subclass removed, cleaning up\n");
 | 
|---|
| 1213 |       /* clean up our heap and reset the origional window procedure */
 | 
|---|
| 1214 |       if (IsWindowUnicode (hWnd))
 | 
|---|
| 1215 |          SetWindowLongW (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
 | 
|---|
| 1216 |       else
 | 
|---|
| 1217 |          SetWindowLongA (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
 | 
|---|
| 1218 |       HeapFree (GetProcessHeap (), 0, stack);
 | 
|---|
| 1219 |       RemovePropA( hWnd, COMCTL32_aSubclass );
 | 
|---|
| 1220 |       return TRUE;
 | 
|---|
| 1221 |    }
 | 
|---|
| 1222 |  
 | 
|---|
| 1223 |    for (n = stack->stacknum + stack->stacknew - 1; n >= 0; n--)
 | 
|---|
| 1224 |       if ((stack->SubclassProcs[n].id == uID) &&
 | 
|---|
| 1225 |          (stack->SubclassProcs[n].subproc == pfnSubclass)) {
 | 
|---|
| 1226 |          if (n != (stack->stacknum + stack->stacknew))
 | 
|---|
| 1227 |             /* Fill the hole in the stack */
 | 
|---|
| 1228 |             memmove (&stack->SubclassProcs[n], &stack->SubclassProcs[n + 1],
 | 
|---|
| 1229 |                     sizeof(stack->SubclassProcs[0]) * (stack->stacknew + stack->stacknum - n));
 | 
|---|
| 1230 |          stack->SubclassProcs[n].subproc = NULL;
 | 
|---|
| 1231 |          stack->SubclassProcs[n].ref = 0;
 | 
|---|
| 1232 |          stack->SubclassProcs[n].id = 0;
 | 
|---|
| 1233 | 
 | 
|---|
| 1234 |          /* If we are currently running a window procedure we have to manipulate
 | 
|---|
| 1235 |           * the stack position pointers so that we don't corrupt the stack */
 | 
|---|
| 1236 |          if ((n < stack->stackpos) || (stack->stackpos == stack->stacknum)) {
 | 
|---|
| 1237 |             stack->stacknum--;
 | 
|---|
| 1238 |             stack->stackpos--;
 | 
|---|
| 1239 |          } else if (n >= stack->stackpos)
 | 
|---|
| 1240 |             stack->stacknew--;
 | 
|---|
| 1241 |          return TRUE;
 | 
|---|
| 1242 |       }
 | 
|---|
| 1243 | 
 | 
|---|
| 1244 |    return FALSE;
 | 
|---|
| 1245 | }
 | 
|---|
| 1246 | 
 | 
|---|
| 1247 | 
 | 
|---|
| 1248 | /***********************************************************************
 | 
|---|
| 1249 |  * DefSubclassProc [COMCTL32.413]
 | 
|---|
| 1250 |  *
 | 
|---|
| 1251 |  * Calls the next window procedure (ie. the one before this subclass)
 | 
|---|
| 1252 |  *
 | 
|---|
| 1253 |  * PARAMS
 | 
|---|
| 1254 |  *     hWnd [in] The window that we're subclassing
 | 
|---|
| 1255 |  *     uMsg [in] Message
 | 
|---|
| 1256 |  *     wParam [in] WPARAM
 | 
|---|
| 1257 |  *     lParam [in] LPARAM
 | 
|---|
| 1258 |  *
 | 
|---|
| 1259 |  * RETURNS
 | 
|---|
| 1260 |  *     Success: non-zero
 | 
|---|
| 1261 |  *     Failure: zero
 | 
|---|
| 1262 |  */
 | 
|---|
| 1263 | 
 | 
|---|
| 1264 | LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 | 
|---|
| 1265 | {
 | 
|---|
| 1266 |    LPSUBCLASS_INFO stack;
 | 
|---|
| 1267 |    int stackpos;
 | 
|---|
| 1268 |    LRESULT ret;
 | 
|---|
| 1269 | 
 | 
|---|
| 1270 |    /* retrieve our little stack from the Properties */
 | 
|---|
| 1271 |    stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
 | 
|---|
| 1272 |    if (!stack) {
 | 
|---|
| 1273 |       ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
 | 
|---|
| 1274 |       return 0;
 | 
|---|
| 1275 |    }
 | 
|---|
| 1276 | 
 | 
|---|
| 1277 |    /* If we are at pos 0 then we have to call the origional window procedure */
 | 
|---|
| 1278 |    if (stack->stackpos == 0) {
 | 
|---|
| 1279 |       if (IsWindowUnicode (hWnd))
 | 
|---|
| 1280 |          return CallWindowProcW (stack->origproc, hWnd, uMsg, wParam, lParam);
 | 
|---|
| 1281 |       else
 | 
|---|
| 1282 |          return CallWindowProcA (stack->origproc, hWnd, uMsg, wParam, lParam);
 | 
|---|
| 1283 |    }
 | 
|---|
| 1284 | 
 | 
|---|
| 1285 |    stackpos = --stack->stackpos;
 | 
|---|
| 1286 |    /* call the Subclass procedure from the stack */
 | 
|---|
| 1287 |    ret = stack->SubclassProcs[stackpos].subproc (hWnd, uMsg, wParam, lParam,
 | 
|---|
| 1288 |          stack->SubclassProcs[stackpos].id, stack->SubclassProcs[stackpos].ref);
 | 
|---|
| 1289 |    stack->stackpos++;
 | 
|---|
| 1290 | 
 | 
|---|
| 1291 |    if ((stack->stackpos == stack->stacknum) && stack->stacknew) {
 | 
|---|
| 1292 |       stack->stacknum += stack->stacknew;
 | 
|---|
| 1293 |       stack->stackpos += stack->stacknew;
 | 
|---|
| 1294 |       stack->stacknew = 0;
 | 
|---|
| 1295 |    }
 | 
|---|
| 1296 | 
 | 
|---|
| 1297 |    /* If we removed the last entry in our stack while a window procedure was
 | 
|---|
| 1298 |     * running then we have to clean up */
 | 
|---|
| 1299 |    if (stack->stackpos == stack->stacknum == 0) {
 | 
|---|
| 1300 |       TRACE("Last Subclass removed, cleaning up\n");
 | 
|---|
| 1301 |       /* clean up our heap and reset the origional window procedure */
 | 
|---|
| 1302 |       if (IsWindowUnicode (hWnd))
 | 
|---|
| 1303 |          SetWindowLongW (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
 | 
|---|
| 1304 |       else
 | 
|---|
| 1305 |          SetWindowLongA (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
 | 
|---|
| 1306 |       HeapFree (GetProcessHeap (), 0, stack);
 | 
|---|
| 1307 |       RemovePropA( hWnd, COMCTL32_aSubclass );
 | 
|---|
| 1308 |       return TRUE;
 | 
|---|
| 1309 |    }
 | 
|---|
| 1310 | 
 | 
|---|
| 1311 |    return ret;
 | 
|---|
| 1312 | }
 | 
|---|
| 1313 | 
 | 
|---|
| 1314 | 
 | 
|---|
| 1315 | /***********************************************************************
 | 
|---|
| 1316 |  * COMCTL32_CreateToolTip [NOT AN API]
 | 
|---|
| 1317 |  *
 | 
|---|
| 1318 |  * Creates a tooltip for the control specified in hwnd and does all
 | 
|---|
| 1319 |  * necessary setup and notifications.
 | 
|---|
| 1320 |  *
 | 
|---|
| 1321 |  * PARAMS
 | 
|---|
| 1322 |  *     hwndOwner [I] Handle to the window that will own the tool tip.
 | 
|---|
| 1323 |  *
 | 
|---|
| 1324 |  * RETURNS
 | 
|---|
| 1325 |  *     Success: Handle of tool tip window.
 | 
|---|
| 1326 |  *     Failure: NULL
 | 
|---|
| 1327 |  */
 | 
|---|
| 1328 | 
 | 
|---|
| 1329 | HWND
 | 
|---|
| 1330 | COMCTL32_CreateToolTip(HWND hwndOwner)
 | 
|---|
| 1331 | {
 | 
|---|
| 1332 |     HWND hwndToolTip;
 | 
|---|
| 1333 | 
 | 
|---|
| 1334 |     hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
 | 
|---|
| 1335 |                                   CW_USEDEFAULT, CW_USEDEFAULT,
 | 
|---|
| 1336 |                                   CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
 | 
|---|
| 1337 |                                   0, 0, 0);
 | 
|---|
| 1338 | 
 | 
|---|
| 1339 |     /* Send NM_TOOLTIPSCREATED notification */
 | 
|---|
| 1340 |     if (hwndToolTip)
 | 
|---|
| 1341 |     {
 | 
|---|
| 1342 |         NMTOOLTIPSCREATED nmttc;
 | 
|---|
| 1343 |         /* true owner can be different if hwndOwner is a child window */
 | 
|---|
| 1344 |         HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER);
 | 
|---|
| 1345 |         nmttc.hdr.hwndFrom = hwndTrueOwner;
 | 
|---|
| 1346 |         nmttc.hdr.idFrom = GetWindowLongA(hwndTrueOwner, GWL_ID);
 | 
|---|
| 1347 |         nmttc.hdr.code = NM_TOOLTIPSCREATED;
 | 
|---|
| 1348 |         nmttc.hwndToolTips = hwndToolTip;
 | 
|---|
| 1349 | 
 | 
|---|
| 1350 |        SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY,
 | 
|---|
| 1351 |                     (WPARAM)GetWindowLongA(hwndTrueOwner, GWL_ID),
 | 
|---|
| 1352 |                      (LPARAM)&nmttc);
 | 
|---|
| 1353 |     }
 | 
|---|
| 1354 | 
 | 
|---|
| 1355 |     return hwndToolTip;
 | 
|---|
| 1356 | }
 | 
|---|
| 1357 | 
 | 
|---|
| 1358 | 
 | 
|---|
| 1359 | /***********************************************************************
 | 
|---|
| 1360 |  * COMCTL32_RefreshSysColors [NOT AN API]
 | 
|---|
| 1361 |  *
 | 
|---|
| 1362 |  * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to
 | 
|---|
| 1363 |  * refresh the color values in the color structure
 | 
|---|
| 1364 |  *
 | 
|---|
| 1365 |  * PARAMS
 | 
|---|
| 1366 |  *     none
 | 
|---|
| 1367 |  *
 | 
|---|
| 1368 |  * RETURNS
 | 
|---|
| 1369 |  *     none
 | 
|---|
| 1370 |  */
 | 
|---|
| 1371 | 
 | 
|---|
| 1372 | VOID
 | 
|---|
| 1373 | COMCTL32_RefreshSysColors(void)
 | 
|---|
| 1374 | {
 | 
|---|
| 1375 |     comctl32_color.clrBtnHighlight = GetSysColor (COLOR_BTNHIGHLIGHT);
 | 
|---|
| 1376 |     comctl32_color.clrBtnShadow = GetSysColor (COLOR_BTNSHADOW);
 | 
|---|
| 1377 |     comctl32_color.clrBtnText = GetSysColor (COLOR_BTNTEXT);
 | 
|---|
| 1378 |     comctl32_color.clrBtnFace = GetSysColor (COLOR_BTNFACE);
 | 
|---|
| 1379 |     comctl32_color.clrHighlight = GetSysColor (COLOR_HIGHLIGHT);
 | 
|---|
| 1380 |     comctl32_color.clrHighlightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
 | 
|---|
| 1381 |     comctl32_color.clr3dHilight = GetSysColor (COLOR_3DHILIGHT);
 | 
|---|
| 1382 |     comctl32_color.clr3dShadow = GetSysColor (COLOR_3DSHADOW);
 | 
|---|
| 1383 |     comctl32_color.clr3dDkShadow = GetSysColor (COLOR_3DDKSHADOW);
 | 
|---|
| 1384 |     comctl32_color.clr3dFace = GetSysColor (COLOR_3DFACE);
 | 
|---|
| 1385 |     comctl32_color.clrWindow = GetSysColor (COLOR_WINDOW);
 | 
|---|
| 1386 |     comctl32_color.clrWindowText = GetSysColor (COLOR_WINDOWTEXT);
 | 
|---|
| 1387 |     comctl32_color.clrGrayText = GetSysColor (COLOR_GRAYTEXT);
 | 
|---|
| 1388 |     comctl32_color.clrActiveCaption = GetSysColor (COLOR_ACTIVECAPTION);
 | 
|---|
| 1389 |     comctl32_color.clrInfoBk = GetSysColor (COLOR_INFOBK);
 | 
|---|
| 1390 |     comctl32_color.clrInfoText = GetSysColor (COLOR_INFOTEXT);
 | 
|---|
| 1391 | }
 | 
|---|