comctl32/tests: Initialize subitem index.
[wine] / dlls / comctl32 / commctrl.c
index 2f08f75..a82b233 100644 (file)
@@ -29,8 +29,6 @@
  *
  * TODO
  *   -- implement GetMUILanguage + InitMUILanguage
- *   -- LibMain => DLLMain ("DLLMain takes over the functionality of both the
- *                           LibMain and the WEP function.", MSDN)
  *   -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
  *   -- FIXMEs + BUGS (search for them)
  *
 
 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
 
-LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
-LPWSTR  COMCTL32_wSubclass = NULL;
+#define NAME       "microsoft.windows.common-controls"
+#define FILE       "comctl32.dll"
+#define VERSION    "6.0.2600.2982"
+#define PUBLIC_KEY "6595b64144ccf1df"
+
+#ifdef __i386__
+#define ARCH "x86"
+#elif defined __x86_64__
+#define ARCH "amd64"
+#else
+#define ARCH "none"
+#endif
+
+static const char manifest[] =
+    "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
+    "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n"
+    "  <assemblyIdentity type=\"win32\" name=\"" NAME "\" version=\"" VERSION "\" processorArchitecture=\"" ARCH "\" publicKeyToken=\"" PUBLIC_KEY "\"/>\n"
+    "  <file name=\"" FILE "\">\n"
+    "    <windowClass>Button</windowClass>\n"
+    "    <windowClass>ButtonListBox</windowClass>\n"
+    "    <windowClass>ComboBoxEx32</windowClass>\n"
+    "    <windowClass>ComboLBox</windowClass>\n"
+    "    <windowClass>Combobox</windowClass>\n"
+    "    <windowClass>Edit</windowClass>\n"
+    "    <windowClass>Listbox</windowClass>\n"
+    "    <windowClass>NativeFontCtl</windowClass>\n"
+    "    <windowClass>ReBarWindow32</windowClass>\n"
+    "    <windowClass>ScrollBar</windowClass>\n"
+    "    <windowClass>Static</windowClass>\n"
+    "    <windowClass>SysAnimate32</windowClass>\n"
+    "    <windowClass>SysDateTimePick32</windowClass>\n"
+    "    <windowClass>SysHeader32</windowClass>\n"
+    "    <windowClass>SysIPAddress32</windowClass>\n"
+    "    <windowClass>SysLink</windowClass>\n"
+    "    <windowClass>SysListView32</windowClass>\n"
+    "    <windowClass>SysMonthCal32</windowClass>\n"
+    "    <windowClass>SysPager</windowClass>\n"
+    "    <windowClass>SysTabControl32</windowClass>\n"
+    "    <windowClass>SysTreeView32</windowClass>\n"
+    "    <windowClass>ToolbarWindow32</windowClass>\n"
+    "    <windowClass>msctls_hotkey32</windowClass>\n"
+    "    <windowClass>msctls_progress32</windowClass>\n"
+    "    <windowClass>msctls_statusbar32</windowClass>\n"
+    "    <windowClass>msctls_trackbar32</windowClass>\n"
+    "    <windowClass>msctls_updown32</windowClass>\n"
+    "    <windowClass>tooltips_class32</windowClass>\n"
+    "  </file>\n"
+    "</assembly>\n";
+
+static const char manifest_filename[] = ARCH "_" NAME "_" PUBLIC_KEY "_" VERSION "_none_deadbeef.manifest";
+
+static LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+static LPWSTR COMCTL32_wSubclass = NULL;
 HMODULE COMCTL32_hModule = 0;
-LANGID  COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
+static LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
 HBRUSH  COMCTL32_hPattern55AABrush = NULL;
 COMCTL32_SysColor  comctl32_color;
 
@@ -93,6 +143,47 @@ static const WCHAR strCC32SubclassInfo[] = {
     'C','C','3','2','S','u','b','c','l','a','s','s','I','n','f','o',0
 };
 
+static BOOL create_manifest( BOOL install )
+{
+    static const WCHAR winsxsW[] = {'\\','w','i','n','s','x','s',0};
+    static const WCHAR manifestsW[] = {'\\','m','a','n','i','f','e','s','t','s','\\',0};
+
+    DWORD len, written;
+    WCHAR *buffer;
+    HANDLE file;
+    BOOL ret = FALSE;
+
+    len = MultiByteToWideChar( CP_UTF8, 0, manifest_filename, sizeof(manifest_filename), NULL, 0 );
+    len += GetWindowsDirectoryW( NULL, 0 );
+    len += lstrlenW(winsxsW);
+    len += lstrlenW(manifestsW);
+    if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE;
+    GetWindowsDirectoryW( buffer, len );
+    lstrcatW( buffer, winsxsW );
+    CreateDirectoryW( buffer, NULL );
+    lstrcatW( buffer, manifestsW );
+    CreateDirectoryW( buffer, NULL );
+    MultiByteToWideChar( CP_UTF8, 0, manifest_filename, sizeof(manifest_filename),
+                         buffer + lstrlenW(buffer), len );
+    if (install)
+    {
+        file = CreateFileW( buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
+        if (file != INVALID_HANDLE_VALUE)
+        {
+            ret = (WriteFile( file, manifest, sizeof(manifest)-1, &written, NULL ) &&
+                   written == sizeof(manifest)-1);
+            CloseHandle( file );
+            if (!ret) DeleteFileW( buffer );
+            else TRACE("created %s\n", debugstr_w(buffer));
+        }
+    }
+    else ret = DeleteFileW( buffer );
+
+    HeapFree( GetProcessHeap(), 0, buffer );
+    return ret;
+}
+
+
 /***********************************************************************
  * DllMain [Internal]
  *
@@ -116,7 +207,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
        case DLL_PROCESS_ATTACH:
             DisableThreadLibraryCalls(hinstDLL);
 
-            COMCTL32_hModule = (HMODULE)hinstDLL;
+            COMCTL32_hModule = hinstDLL;
 
             /* add global subclassing atom (used by 'tooltip' and 'updown') */
             COMCTL32_wSubclass = (LPWSTR)(DWORD_PTR)GlobalAddAtomW (strCC32SubclassInfo);
@@ -129,13 +220,20 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
            /* Get all the colors at DLL load */
            COMCTL32_RefreshSysColors();
 
-            /* register all Win95 common control classes */
+            /* like comctl32 5.82+ register all the common control classes */
             ANIMATE_Register ();
+            COMBOEX_Register ();
+            DATETIME_Register ();
             FLATSB_Register ();
             HEADER_Register ();
             HOTKEY_Register ();
+            IPADDRESS_Register ();
             LISTVIEW_Register ();
+            MONTHCAL_Register ();
+            NATIVEFONT_Register ();
+            PAGER_Register ();
             PROGRESS_Register ();
+            REBAR_Register ();
             STATUS_Register ();
             SYSLINK_Register ();
             TAB_Register ();
@@ -234,7 +332,7 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
 
     switch (uMsg) {
        case WM_MENUSELECT:
-           TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
+           TRACE("WM_MENUSELECT wParam=0x%lX lParam=0x%lX\n",
                   wParam, lParam);
 
             if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
@@ -245,7 +343,7 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
            else {
                /* menu item was selected */
                if (HIWORD(wParam) & MF_POPUP)
-                   uMenuID = (UINT)*(lpwIDs+1);
+                   uMenuID = *(lpwIDs+1);
                else
                    uMenuID = (UINT)LOWORD(wParam);
                TRACE("uMenuID = %u\n", uMenuID);
@@ -264,7 +362,7 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
            break;
 
         case WM_COMMAND :
-           TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
+           TRACE("WM_COMMAND wParam=0x%lX lParam=0x%lX\n",
                   wParam, lParam);
            /* WM_COMMAND is not invalid since it is documented
             * in the windows api reference. So don't output
@@ -315,7 +413,7 @@ ShowHideMenuCtl (HWND hwnd, UINT_PTR uFlags, LPINT lpInfo)
 {
     LPINT lpMenuId;
 
-    TRACE("%p, %x, %p\n", hwnd, uFlags, lpInfo);
+    TRACE("%p, %lx, %p\n", hwnd, uFlags, lpInfo);
 
     if (lpInfo == NULL)
        return FALSE;
@@ -373,10 +471,10 @@ ShowHideMenuCtl (HWND hwnd, UINT_PTR uFlags, LPINT lpInfo)
  */
 
 VOID WINAPI
-GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
+GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, const INT *lpInfo)
 {
     RECT rcCtrl;
-    INT  *lpRun;
+    const INT *lpRun;
     HWND hwndCtrl;
 
     TRACE("(%p %p %p)\n",
@@ -421,7 +519,7 @@ GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
  *     (will be written ...)
  */
 
-void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
+void WINAPI DrawStatusTextW (HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style)
 {
     RECT r = *lprc;
     UINT border = BDR_SUNKENOUTER;
@@ -437,18 +535,27 @@ void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
     if (text) {
         int oldbkmode = SetBkMode (hdc, TRANSPARENT);
         UINT align = DT_LEFT;
-        if (*text == L'\t') {
-           text++;
-           align = DT_CENTER;
-           if (*text == L'\t') {
-               text++;
-               align = DT_RIGHT;
-           }
-        }
-        r.left += 3;
+        int strCnt = 0;
+
         if (style & SBT_RTLREADING)
-           FIXME("Unsupported RTL style!\n");
-        DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
+            FIXME("Unsupported RTL style!\n");
+        r.left += 3;
+        do {
+            if (*text == '\t') {
+                if (strCnt) {
+                    DrawTextW (hdc, text - strCnt, strCnt, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
+                    strCnt = 0;
+                }
+                if (align==DT_RIGHT) {
+                    break;
+                }
+                align = (align==DT_LEFT ? DT_CENTER : DT_RIGHT);
+            } else {
+                strCnt++;
+            }
+        } while(*text++);
+
+        if (strCnt) DrawTextW (hdc, text - strCnt, -1, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
        SetBkMode(hdc, oldbkmode);
     }
 }
@@ -470,7 +577,7 @@ void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
  *     No return value.
  */
 
-void WINAPI DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
+void WINAPI DrawStatusTextA (HDC hdc, LPCRECT lprc, LPCSTR text, UINT style)
 {
     INT len;
     LPWSTR textW = NULL;
@@ -593,9 +700,8 @@ CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
  *     No return values.
  *
  * NOTES
- *     This function is just a dummy.
- *     The Win95 controls are registered at the DLL's initialization.
- *     To register other controls InitCommonControlsEx() must be used.
+ *     This function is just a dummy - all the controls are registered at
+ *     the DLL's initialization. See InitCommonContolsEx for details.
  */
 
 VOID WINAPI
@@ -617,81 +723,24 @@ InitCommonControls (void)
  *     Failure: FALSE
  *
  * NOTES
- *     Only the additional common controls are registered by this function.
- *     The Win95 controls are registered at the DLL's initialization.
- *
- * FIXME
- *     implement the following control classes:
- *       ICC_LINK_CLASS
- *       ICC_STANDARD_CLASSES
+ *     Probably all versions of comctl32 initializes the Win95 controls in DllMain
+ *     during DLL initialization. Starting from comctl32 v5.82 all the controls
+ *     are initialized there. We follow this behaviour and this function is just
+ *     a dummy.
+ *
+ *     Note: when writing programs under Windows, if you don't call any function
+ *     from comctl32 the linker may not link this DLL. If InitCommonControlsEx
+ *     was the only comctl32 function you were calling and you remove it you may
+ *     have a false impression that InitCommonControlsEx actually did something.
  */
 
 BOOL WINAPI
-InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
+InitCommonControlsEx (const INITCOMMONCONTROLSEX *lpInitCtrls)
 {
-    INT cCount;
-    DWORD dwMask;
-
-    if (!lpInitCtrls)
-       return FALSE;
-    if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
-       return FALSE;
+    if (!lpInitCtrls || lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
+        return FALSE;
 
     TRACE("(0x%08x)\n", lpInitCtrls->dwICC);
-
-    for (cCount = 0; cCount < 32; cCount++) {
-       dwMask = 1 << cCount;
-       if (!(lpInitCtrls->dwICC & dwMask))
-           continue;
-
-       switch (lpInitCtrls->dwICC & dwMask) {
-           /* dummy initialization */
-           case ICC_ANIMATE_CLASS:
-           case ICC_BAR_CLASSES:
-           case ICC_LISTVIEW_CLASSES:
-           case ICC_TREEVIEW_CLASSES:
-           case ICC_TAB_CLASSES:
-           case ICC_UPDOWN_CLASS:
-           case ICC_PROGRESS_CLASS:
-           case ICC_HOTKEY_CLASS:
-               break;
-
-           /* advanced classes - not included in Win95 */
-           case ICC_DATE_CLASSES:
-               MONTHCAL_Register ();
-               DATETIME_Register ();
-               break;
-
-           case ICC_USEREX_CLASSES:
-               COMBOEX_Register ();
-               break;
-
-           case ICC_COOL_CLASSES:
-               REBAR_Register ();
-               break;
-
-           case ICC_INTERNET_CLASSES:
-               IPADDRESS_Register ();
-               break;
-
-           case ICC_PAGESCROLLER_CLASS:
-               PAGER_Register ();
-               break;
-
-           case ICC_NATIVEFNTCTL_CLASS:
-               NATIVEFONT_Register ();
-               break;
-
-           case ICC_LINK_CLASS:
-               SYSLINK_Register ();
-               break;
-
-           default:
-               FIXME("Unknown class! dwICC=0x%X\n", dwMask);
-               break;
-       }
-    }
-
     return TRUE;
 }
 
@@ -723,7 +772,7 @@ InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
 
 HWND WINAPI
 CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
-                 HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
+                 HINSTANCE hBMInst, UINT_PTR wBMID, LPCTBBUTTON lpButtons,
                  INT iNumButtons, INT dxButton, INT dyButton,
                  INT dxBitmap, INT dyBitmap, UINT uStructSize)
 {
@@ -735,37 +784,38 @@ CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
     if(hwndTB) {
        TBADDBITMAP tbab;
 
-        SendMessageW (hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM)uStructSize, 0);
+        SendMessageW (hwndTB, TB_BUTTONSTRUCTSIZE, uStructSize, 0);
 
        /* set bitmap and button size */
        /*If CreateToolbarEx receives 0, windows sets default values*/
-       if (dxBitmap <= 0)
+       if (dxBitmap < 0)
            dxBitmap = 16;
-       if (dyBitmap <= 0)
-           dyBitmap = 15;
-       SendMessageW (hwndTB, TB_SETBITMAPSIZE, 0,
-                     MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
+       if (dyBitmap < 0)
+           dyBitmap = 16;
+       if (dxBitmap == 0 || dyBitmap == 0)
+           dxBitmap = dyBitmap = 16;
+       SendMessageW(hwndTB, TB_SETBITMAPSIZE, 0, MAKELPARAM(dxBitmap, dyBitmap));
 
-       if (dxButton <= 0)
-           dxButton = 24;
-       if (dyButton <= 0)
-           dyButton = 22;
-       SendMessageW (hwndTB, TB_SETBUTTONSIZE, 0,
-                     MAKELPARAM((WORD)dxButton, (WORD)dyButton));
+       if (dxButton < 0)
+           dxButton = dxBitmap;
+       if (dyButton < 0)
+           dyButton = dyBitmap;
+       /* TB_SETBUTTONSIZE -> TB_SETBITMAPSIZE bug introduced for Windows compatibility */
+       if (dxButton != 0 && dyButton != 0)
+            SendMessageW(hwndTB, TB_SETBITMAPSIZE, 0, MAKELPARAM(dxButton, dyButton));
 
 
        /* add bitmaps */
-       if (nBitmaps > 0)
+       if (nBitmaps > 0 || hBMInst == HINST_COMMCTRL)
        {
            tbab.hInst = hBMInst;
            tbab.nID   = wBMID;
 
-           SendMessageW (hwndTB, TB_ADDBITMAP, (WPARAM)nBitmaps, (LPARAM)&tbab);
+            SendMessageW (hwndTB, TB_ADDBITMAP, nBitmaps, (LPARAM)&tbab);
        }
        /* add buttons */
        if(iNumButtons > 0)
-       SendMessageW (hwndTB, TB_ADDBUTTONSW,
-                       (WPARAM)iNumButtons, (LPARAM)lpButtons);
+        SendMessageW (hwndTB, TB_ADDBUTTONSW, iNumButtons, (LPARAM)lpButtons);
     }
 
     return hwndTB;
@@ -795,7 +845,8 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
 {
     HGLOBAL hglb;
     HRSRC hRsrc;
-    LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
+    const BITMAPINFOHEADER *lpBitmap;
+    LPBITMAPINFOHEADER lpBitmapInfo;
     UINT nSize, nColorTableSize, iColor;
     RGBQUAD *pColorTable;
     INT i, iMaps, nWidth, nHeight;
@@ -817,7 +868,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
        internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
        internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
        iMaps = 4;
-       sysColorMap = (LPCOLORMAP)internalColorMap;
+       sysColorMap = internalColorMap;
     }
 
     hRsrc = FindResourceW (hInstance, (LPWSTR)idBitmap, (LPWSTR)RT_BITMAP);
@@ -826,7 +877,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
     hglb = LoadResource (hInstance, hRsrc);
     if (hglb == 0)
        return 0;
-    lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
+    lpBitmap = LockResource (hglb);
     if (lpBitmap == NULL)
        return 0;
 
@@ -837,12 +888,12 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
     else
         nColorTableSize = 0;
     nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
-    lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
+    lpBitmapInfo = GlobalAlloc (GMEM_FIXED, nSize);
     if (lpBitmapInfo == NULL)
        return 0;
     RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
 
-    pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
+    pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo) + lpBitmapInfo->biSize);
 
     for (iColor = 0; iColor < nColorTableSize; iColor++) {
        for (i = 0; i < iMaps; i++) {
@@ -864,15 +915,14 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
            }
        }
     }
-    nWidth  = (INT)lpBitmapInfo->biWidth;
-    nHeight = (INT)lpBitmapInfo->biHeight;
+    nWidth  = lpBitmapInfo->biWidth;
+    nHeight = lpBitmapInfo->biHeight;
     hdcScreen = GetDC (NULL);
     hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
     if (hbm) {
        HDC hdcDst = CreateCompatibleDC (hdcScreen);
        HBITMAP hbmOld = SelectObject (hdcDst, hbm);
-       LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
-       lpBits += nColorTableSize * sizeof(RGBQUAD);
+       const BYTE *lpBits = (const BYTE *)lpBitmap + nSize;
        StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
                         lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
                         SRCCOPY);
@@ -880,7 +930,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
        DeleteDC (hdcDst);
     }
     ReleaseDC (NULL, hdcScreen);
-    GlobalFree ((HGLOBAL)lpBitmapInfo);
+    GlobalFree (lpBitmapInfo);
     FreeResource (hglb);
 
     return hbm;
@@ -967,10 +1017,9 @@ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
  */
 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
 {
-  FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
-       debugstr_w(cmdline));
-
-  return S_OK;
+    TRACE("(%u, %s): stub\n", bInstall, debugstr_w(cmdline));
+    if (!create_manifest( bInstall )) return HRESULT_FROM_WIN32(GetLastError());
+    return S_OK;
 }
 
 /***********************************************************************
@@ -1049,7 +1098,7 @@ VOID WINAPI InitMUILanguage (LANGID uiLang)
  * BUGS
  *     If an application manually subclasses a window after subclassing it with
  *     this API and then with this API again, then none of the previous 
- *     subclasses get called or the origional window procedure.
+ *     subclasses get called or the original window procedure.
  */
 
 BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
@@ -1058,7 +1107,7 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
    LPSUBCLASS_INFO stack;
    LPSUBCLASSPROCS proc;
 
-   TRACE ("(%p, %p, %x, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
+   TRACE ("(%p, %p, %lx, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
 
    /* Since the window procedure that we set here has two additional arguments,
     * we can't simply set it as the new window procedure of the window. So we
@@ -1066,7 +1115,7 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
     * from there. */
 
    /* See if we have been called for this window */
-   stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
+   stack = GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack) {
       /* allocate stack */
       stack = Alloc (sizeof(SUBCLASS_INFO));
@@ -1074,7 +1123,7 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
          ERR ("Failed to allocate our Subclassing stack\n");
          return FALSE;
       }
-      SetPropW (hWnd, COMCTL32_wSubclass, (HANDLE)stack);
+      SetPropW (hWnd, COMCTL32_wSubclass, stack);
 
       /* set window procedure to our own and save the current one */
       if (IsWindowUnicode (hWnd))
@@ -1139,13 +1188,13 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
 BOOL WINAPI GetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
                               UINT_PTR uID, DWORD_PTR *pdwRef)
 {
-   LPSUBCLASS_INFO stack;
-   LPSUBCLASSPROCS proc;
+   const SUBCLASS_INFO *stack;
+   const SUBCLASSPROCS *proc;
 
-   TRACE ("(%p, %p, %x, %p)\n", hWnd, pfnSubclass, uID, pdwRef);
+   TRACE ("(%p, %p, %lx, %p)\n", hWnd, pfnSubclass, uID, pdwRef);
 
    /* See if we have been called for this window */
-   stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
+   stack = GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack)
       return FALSE;
 
@@ -1185,10 +1234,10 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u
    LPSUBCLASSPROCS proc;
    BOOL ret = FALSE;
 
-   TRACE ("(%p, %p, %x)\n", hWnd, pfnSubclass, uID);
+   TRACE ("(%p, %p, %lx)\n", hWnd, pfnSubclass, uID);
 
    /* Find the Subclass to remove */
-   stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
+   stack = GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack)
       return FALSE;
 
@@ -1215,7 +1264,7 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u
    
    if (!stack->SubclassProcs && !stack->running) {
       TRACE("Last Subclass removed, cleaning up\n");
-      /* clean up our heap and reset the origional window procedure */
+      /* clean up our heap and reset the original window procedure */
       if (IsWindowUnicode (hWnd))
          SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
       else
@@ -1233,15 +1282,15 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u
  * Window procedure for all subclassed windows. 
  * Saves the current subclassing stack position to support nested messages
  */
-LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
    LPSUBCLASS_INFO stack;
    LPSUBCLASSPROCS proc;
    LRESULT ret;
     
-   TRACE ("(%p, 0x%08x, 0x%08x, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
+   TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
 
-   stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
+   stack = GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack) {
       ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
       return 0;
@@ -1257,7 +1306,7 @@ LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
     
    if (!stack->SubclassProcs && !stack->running) {
       TRACE("Last Subclass removed, cleaning up\n");
-      /* clean up our heap and reset the origional window procedure */
+      /* clean up our heap and reset the original window procedure */
       if (IsWindowUnicode (hWnd))
          SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
       else
@@ -1289,10 +1338,10 @@ LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
    LPSUBCLASS_INFO stack;
    LRESULT ret;
    
-   TRACE ("(%p, 0x%08x, 0x%08x, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
+   TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
 
    /* retrieve our little stack from the Properties */
-   stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
+   stack = GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack) {
       ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
       return 0;
@@ -1306,7 +1355,7 @@ LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
       else
          ret = CallWindowProcA (stack->origproc, hWnd, uMsg, wParam, lParam);
    } else {
-      LPSUBCLASSPROCS proc = stack->stackpos;
+      const SUBCLASSPROCS *proc = stack->stackpos;
       stack->stackpos = stack->stackpos->next; 
       /* call the Subclass procedure from the stack */
       ret = proc->subproc (hWnd, uMsg, wParam, lParam,
@@ -1352,9 +1401,8 @@ COMCTL32_CreateToolTip(HWND hwndOwner)
        nmttc.hdr.code = NM_TOOLTIPSCREATED;
        nmttc.hwndToolTips = hwndToolTip;
 
-       SendMessageW(GetParent(hwndTrueOwner), WM_NOTIFY,
-                    (WPARAM)GetWindowLongPtrW(hwndTrueOwner, GWLP_ID),
-                   (LPARAM)&nmttc);
+        SendMessageW(GetParent(hwndTrueOwner), WM_NOTIFY,
+                     GetWindowLongPtrW(hwndTrueOwner, GWLP_ID), (LPARAM)&nmttc);
     }
 
     return hwndToolTip;
@@ -1383,6 +1431,7 @@ COMCTL32_RefreshSysColors(void)
     comctl32_color.clrBtnFace = GetSysColor (COLOR_BTNFACE);
     comctl32_color.clrHighlight = GetSysColor (COLOR_HIGHLIGHT);
     comctl32_color.clrHighlightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
+    comctl32_color.clrHotTrackingColor = GetSysColor (COLOR_HOTLIGHT);
     comctl32_color.clr3dHilight = GetSysColor (COLOR_3DHILIGHT);
     comctl32_color.clr3dShadow = GetSysColor (COLOR_3DSHADOW);
     comctl32_color.clr3dDkShadow = GetSysColor (COLOR_3DDKSHADOW);
@@ -1451,15 +1500,15 @@ void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark
 /***********************************************************************
  * COMCTL32_EnsureBitmapSize [internal]
  *
- * If needed enlarge the bitmap so that the width is at least cxMinWidth
- * the height is at least cyMinHeight. If the bitmap already have these
+ * If needed, enlarge the bitmap so that the width is at least cxMinWidth and
+ * the height is at least cyMinHeight. If the bitmap already has these
  * dimensions nothing changes.
  *
  * PARAMS
  *     hBitmap       [I/O] Bitmap to modify. The handle may change
- *     cxMinWidth    [I]   If the width of the bitmap is smaller then it will
+ *     cxMinWidth    [I]   If the width of the bitmap is smaller, then it will
  *                         be enlarged to this value
- *     cyMinHeight   [I]   If the height of the bitmap is smaller then it will
+ *     cyMinHeight   [I]   If the height of the bitmap is smaller, then it will
  *                         be enlarged to this value
  *     cyBackground  [I]   The color with which the new area will be filled
  *
@@ -1509,6 +1558,61 @@ void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight
     return;
 }
 
+void COMCTL32_GetFontMetrics(HFONT hFont, TEXTMETRICW *ptm)
+{
+    HDC hdc = GetDC(NULL);
+    HFONT hOldFont;
+
+    hOldFont = SelectObject(hdc, hFont);
+    GetTextMetricsW(hdc, ptm);
+    SelectObject(hdc, hOldFont);
+    ReleaseDC(NULL, hdc);
+}
+
+#ifndef OCM__BASE      /* avoid including olectl.h */
+#define OCM__BASE (WM_USER+0x1c00)
+#endif
+
+/***********************************************************************
+ * COMCTL32_IsReflectedMessage [internal]
+ *
+ * Some parents reflect notify messages - for some messages sent by the child,
+ * they send it back with the message code increased by OCM__BASE (0x2000).
+ * This allows better subclassing of controls. We don't need to handle such
+ * messages but we don't want to print ERRs for them, so this helper function
+ * identifies them.
+ *
+ * Some of the codes are in the CCM_FIRST..CCM_LAST range, but there is no
+ * colision with defined CCM_ codes.
+ */
+BOOL COMCTL32_IsReflectedMessage(UINT uMsg)
+{
+    switch (uMsg)
+    {
+        case OCM__BASE + WM_COMMAND:
+        case OCM__BASE + WM_CTLCOLORBTN:
+        case OCM__BASE + WM_CTLCOLOREDIT:
+        case OCM__BASE + WM_CTLCOLORDLG:
+        case OCM__BASE + WM_CTLCOLORLISTBOX:
+        case OCM__BASE + WM_CTLCOLORMSGBOX:
+        case OCM__BASE + WM_CTLCOLORSCROLLBAR:
+        case OCM__BASE + WM_CTLCOLORSTATIC:
+        case OCM__BASE + WM_DRAWITEM:
+        case OCM__BASE + WM_MEASUREITEM:
+        case OCM__BASE + WM_DELETEITEM:
+        case OCM__BASE + WM_VKEYTOITEM:
+        case OCM__BASE + WM_CHARTOITEM:
+        case OCM__BASE + WM_COMPAREITEM:
+        case OCM__BASE + WM_HSCROLL:
+        case OCM__BASE + WM_VSCROLL:
+        case OCM__BASE + WM_PARENTNOTIFY:
+        case OCM__BASE + WM_NOTIFY:
+            return TRUE;
+        default:
+            return FALSE;
+    }
+}
+
 /***********************************************************************
  * MirrorIcon [COMCTL32.414]
  *
@@ -1541,7 +1645,7 @@ static inline int IsDelimiter(WCHAR c)
     return FALSE;
 }
 
-static int CALLBACK PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
+static int CALLBACK PathWordBreakProc(LPCWSTR lpch, int ichCurrent, int cch, int code)
 {
     if (code == WB_ISDELIMITER)
         return IsDelimiter(lpch[ichCurrent]);
@@ -1572,3 +1676,30 @@ LRESULT WINAPI SetPathWordBreakProc(HWND hwnd, BOOL bSet)
     return SendMessageW(hwnd, EM_SETWORDBREAKPROC, 0,
         (LPARAM)(bSet ? PathWordBreakProc : NULL));
 }
+
+/***********************************************************************
+ * DrawShadowText [COMCTL32.@]
+ *
+ * Draw text with shadow.
+ */
+int WINAPI DrawShadowText(HDC hdc, LPCWSTR pszText, UINT cch, RECT *rect, DWORD dwFlags,
+                          COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset)
+{
+    FIXME("(%p, %s, %d, %p, %d, 0x%08x, 0x%08x, %d, %d): stub\n", hdc, debugstr_w(pszText), cch, rect, dwFlags,
+                                                                  crText, crShadow, ixOffset, iyOffset);
+    return DrawTextW(hdc, pszText, cch, rect, DT_LEFT);
+}
+
+/***********************************************************************
+ * TaskDialogIndirect [COMCTL32.@]
+ */
+HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton,
+                                  int *pnRadioButton, BOOL *pfVerificationFlagChecked)
+{
+    FIXME("%p, %p, %p, %p\n", pTaskConfig, pnButton, pnRadioButton, pfVerificationFlagChecked);
+
+    if (pnButton) *pnButton = IDYES;
+    if (pnRadioButton) *pnRadioButton = pTaskConfig->nDefaultButton;
+    if (pfVerificationFlagChecked) *pfVerificationFlagChecked = TRUE;
+    return S_OK;
+}