Lookup DrawCaptionTemp () only once during startup
authorThomas Bluemel <thomas@reactsoft.com>
Thu, 12 Jun 2008 16:50:57 +0000 (16:50 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Thu, 12 Jun 2008 16:50:57 +0000 (16:50 +0000)
svn path=/trunk/; revision=33950

reactos/base/shell/explorer-new/explorer.c
reactos/base/shell/explorer-new/precomp.h
reactos/base/shell/explorer-new/taskswnd.c
reactos/base/shell/explorer-new/traywnd.c

index 2f7267d..1ee6224 100644 (file)
 #include <precomp.h>
 
 HINSTANCE hExplorerInstance;
+HMODULE hUser32;
 HANDLE hProcessHeap;
 HKEY hkExplorer = NULL;
+DRAWCAPTEMP DrawCapTemp = NULL;
 
 /* undoc GUID */
 DEFINE_GUID(CLSID_RebarBandSite, 0xECD4FC4D, 0x521C, 0x11D0, 0xB7, 0x92, 0x00, 0xA0, 0xC9, 0x03, 0x12, 0xE1);
@@ -289,6 +291,13 @@ _tWinMain(IN HINSTANCE hInstance,
     hExplorerInstance = hInstance;
     hProcessHeap = GetProcessHeap();
 
+    hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
+    if (hUser32 != NULL)
+    {
+        DrawCapTemp = (DRAWCAPTEMP)GetProcAddress(hUser32,
+                                                  PROC_NAME_DRAWCAPTIONTEMP);
+    }
+
     InitCommonControls();
     OleInitialize(NULL);
 
index 4c11af5..bf8fc0e 100644 (file)
@@ -77,8 +77,10 @@ Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
     Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__);
 
 extern HINSTANCE hExplorerInstance;
+extern HMODULE hUser32;
 extern HANDLE hProcessHeap;
 extern HKEY hkExplorer;
+extern DRAWCAPTEMP DrawCapTemp;
 
 /*
  * dragdrop.c
index 29f432b..f4f0370 100644 (file)
@@ -1640,7 +1640,6 @@ TaskSwichWnd_HandleItemPaint(IN OUT PTASK_SWITCH_WND This,
 {
     HFONT hCaptionFont, hBoldCaptionFont;
     LRESULT Ret = CDRF_DODEFAULT;
-    HMODULE hUser32;
     PTASK_GROUP TaskGroup;
     PTASK_ITEM TaskItem;
 
@@ -1701,25 +1700,16 @@ TaskSwichWnd_HandleItemPaint(IN OUT PTASK_SWITCH_WND This,
                     uidctFlags |= DC_ACTIVE;
             }
 
-            hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
-            if (hUser32 != NULL)
+            if (DrawCapTemp != NULL)
             {
-                DRAWCAPTEMP DrawCapTemp;
-
-                /* DrawCaptionTemp */
-                DrawCapTemp = (DRAWCAPTEMP)GetProcAddress(hUser32,
-                                                          PROC_NAME_DRAWCAPTIONTEMP);
-                if (DrawCapTemp != NULL)
-                {
-                    /* Draw the button content */
-                    TaskItem->DisplayTooltip = !DrawCapTemp(TaskItem->hWnd,
-                                                            nmtbcd->nmcd.hdc,
-                                                            &nmtbcd->nmcd.rc,
-                                                            hCaptionFont,
-                                                            NULL,
-                                                            NULL,
-                                                            uidctFlags);
-                }
+                /* Draw the button content */
+                TaskItem->DisplayTooltip = !DrawCapTemp(TaskItem->hWnd,
+                                                        nmtbcd->nmcd.hdc,
+                                                        &nmtbcd->nmcd.rc,
+                                                        hCaptionFont,
+                                                        NULL,
+                                                        NULL,
+                                                        uidctFlags);
             }
 
             return CDRF_SKIPDEFAULT;
index 71dad2b..1f9451d 100644 (file)
@@ -1223,7 +1223,6 @@ ITrayWindowImpl_CreateStartButtonBitmap(IN OUT ITrayWindowImpl *This)
     BOOL Ret;
     UINT Flags;
     RECT rcButton;
-    HMODULE hUser32;
 
     /* NOTE: This is the backwards compatibility code that is used if the
              Common Controls Version 6.0 are not available! */
@@ -1294,24 +1293,15 @@ ITrayWindowImpl_CreateStartButtonBitmap(IN OUT ITrayWindowImpl *This)
     if (hIconStart != NULL)
         Flags |= DC_ICON;
 
-    hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
-    if (hUser32 != NULL)
+    if (DrawCapTemp != NULL)
     {
-        DRAWCAPTEMP DrawCapTemp;
-
-        /* DrawCaptionTemp */
-        DrawCapTemp = (DRAWCAPTEMP)GetProcAddress(hUser32,
-                                                  PROC_NAME_DRAWCAPTIONTEMP);
-        if (DrawCapTemp != NULL)
-        {
-            Ret = DrawCapTemp(NULL,
-                              hDC,
-                              &rcButton,
-                              This->hStartBtnFont,
-                              hIconStart,
-                              szStartCaption,
-                              Flags);
-        }
+        Ret = DrawCapTemp(NULL,
+                          hDC,
+                          &rcButton,
+                          This->hStartBtnFont,
+                          hIconStart,
+                          szStartCaption,
+                          Flags);
     }
 
     SelectObject(hDC,