Author: hbelusca
Date: Fri Feb 12 19:07:29 2016
New Revision: 70717

URL: http://svn.reactos.org/svn/reactos?rev=70717&view=rev
Log:
[UXTHEME]: Use a similar working logic to display (or not) the icon (or the 
default one) to windows/dialogs, taking in particular their exstyle 
WS_EX_DLGMODALFRAME in particular.
Dedicated to Jared Smudde.
CORE-9635 #resolve #comment A better fix was committed in r70717 to match r70715

Modified:
    trunk/reactos/dll/win32/uxtheme/nonclient.c

Modified: trunk/reactos/dll/win32/uxtheme/nonclient.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/nonclient.c?rev=70717&r1=70716&r2=70717&view=diff
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] Fri Feb 12 
19:07:29 2016
@@ -13,20 +13,19 @@
 
 void InitMenuFont(VOID)
 {
-  NONCLIENTMETRICS ncm;
+    NONCLIENTMETRICS ncm;
 
     ncm.cbSize = sizeof(NONCLIENTMETRICS); 
 
-    if(!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
-    {
-      return ;
+    if (!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
+    {
+        return;
     }
 
     hMenuFont = CreateFontIndirect(&ncm.lfMenuFont);
 
     ncm.lfMenuFont.lfWeight = max(ncm.lfMenuFont.lfWeight + 300, 1000);
     hMenuFontBold = CreateFontIndirect(&ncm.lfMenuFont);
-
 }
 
 static BOOL 
@@ -64,26 +63,27 @@
    return FALSE;
 }
 
-HICON
-UserGetWindowIcon(HWND hwnd)
-{
-    HICON hIcon = 0;
-
-    SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 
1000, (PDWORD_PTR)&hIcon);
+static HICON
+UserGetWindowIcon(PDRAW_CONTEXT pcontext)
+{
+    HICON hIcon = NULL;
+
+    SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL2, 0, 
SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
 
     if (!hIcon)
-        SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 
1000, (PDWORD_PTR)&hIcon);
+        SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL, 0, 
SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
 
     if (!hIcon)
-        SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 
1000, (PDWORD_PTR)&hIcon);
+        SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_BIG, 0, 
SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
 
     if (!hIcon)
-        hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
+        hIcon = (HICON)GetClassLong(pcontext->hWnd, GCL_HICONSM);
 
     if (!hIcon)
-        hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
-
-    if(!hIcon)
+        hIcon = (HICON)GetClassLong(pcontext->hWnd, GCL_HICON);
+
+    // See also win32ss/user/ntuser/nonclient.c!NC_IconForWindow
+    if (!hIcon && !(pcontext->wi.dwExStyle & WS_EX_DLGMODALFRAME))
         hIcon = LoadIconW(NULL, (LPCWSTR)IDI_WINLOGO);
 
     return hIcon;
@@ -306,7 +306,7 @@
                            ThemeGetButtonState(HTHELP, htHot, htDown, 
pcontext->Active));
 }
 
-/* Used from WM_NCPAINT and WM_NCACTIVATE handlers*/
+/* Used from WM_NCPAINT and WM_NCACTIVATE handlers */
 static void 
 ThemeDrawCaption(PDRAW_CONTEXT pcontext, RECT* prcCurrent)
 {
@@ -315,7 +315,13 @@
     HICON hIcon;
     WCHAR *CaptionText;
 
-    hIcon = UserGetWindowIcon(pcontext->hWnd);
+    // See also win32ss/user/ntuser/nonclient.c!UserDrawCaptionBar
+    // and win32ss/user/ntuser/nonclient.c!UserDrawCaption
+    if ((pcontext->wi.dwStyle & WS_SYSMENU) && !(pcontext->wi.dwExStyle & 
WS_EX_TOOLWINDOW))
+        hIcon = UserGetWindowIcon(pcontext);
+    else
+        hIcon = NULL;
+
     CaptionText = UserGetWindowCaption(pcontext->hWnd);
 
     /* Get the caption part and state id */
@@ -328,7 +334,7 @@
 
     iState = pcontext->Active ? FS_ACTIVE : FS_INACTIVE;
 
-    /* Draw the caption background*/
+    /* Draw the caption background */
     rcPart = *prcCurrent;
     rcPart.bottom = rcPart.top + pcontext->CaptionHeight;
     prcCurrent->top = rcPart.bottom;
@@ -352,8 +358,7 @@
     rcPart.top += 3 ;
 
     /* Draw the icon */
-    if(hIcon && !(pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW)
-             && !(pcontext->wi.dwExStyle & WS_EX_DLGMODALFRAME))
+    if (hIcon)
     {
         int IconHeight = GetSystemMetrics(SM_CYSMICON);
         int IconWidth = GetSystemMetrics(SM_CXSMICON);
@@ -364,9 +369,9 @@
     rcPart.right -= 4;
 
     /* Draw the caption */
-    if(CaptionText)
-    {
-        /*FIXME: Use DrawThemeTextEx*/
+    if (CaptionText)
+    {
+        /* FIXME: Use DrawThemeTextEx */
         ThemeDrawCaptionText(pcontext->theme, 
                              pcontext->hDC, 
                              iPart,
@@ -375,7 +380,7 @@
                              lstrlenW(CaptionText), 
                              DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS, 
                              0, 
-                             &rcPart , 
+                             &rcPart,
                              pcontext->Active);
         HeapFree(GetProcessHeap(), 0, CaptionText);
     }
@@ -446,7 +451,7 @@
     }
 
     /* Now the other bit of the frame */
-    if (context->wi.dwStyle & (WS_DLGFRAME | WS_BORDER) || 
context->wi.dwExStyle & WS_EX_DLGMODALFRAME)
+    if (context->wi.dwStyle & (WS_DLGFRAME | WS_BORDER) || 
(context->wi.dwExStyle & WS_EX_DLGMODALFRAME))
     {
         INT Width = GetSystemMetrics(SM_CXBORDER);
         INT Height = GetSystemMetrics(SM_CYBORDER);
@@ -594,7 +599,7 @@
     Rect = MenuBarInfo.rcBar;
     OffsetRect(&Rect, -pcontext->wi.rcWindow.left, -pcontext->wi.rcWindow.top);
 
-    /* Draw a line under the menu*/
+    /* Draw a line under the menu */
     oldPen = (HPEN)SelectObject(pcontext->hDC, GetStockObject(DC_PEN));
     SetDCPenColor(pcontext->hDC, GetSysColor(COLOR_3DFACE));
     MoveToEx(pcontext->hDC, Rect.left, Rect.bottom, NULL);
@@ -611,7 +616,7 @@
 
     SelectObject(pcontext->hDC, FontOld);
 
-    /* Fill the menu background area that isn't painted yet*/
+    /* Fill the menu background area that isn't painted yet */
     FillRect(pcontext->hDC, &Rect, GetSysColorBrush(flat_menu ? COLOR_MENUBAR 
: COLOR_MENU));
 }
 
@@ -652,7 +657,7 @@
 }
 
 /*
-    Message handlers
+ * Message handlers
  */
 
 static LRESULT 
@@ -937,7 +942,6 @@
 
         if (!PtInRect(&WindowRect, Point))
         {
-
             INT ButtonWidth;
 
             if (wi.dwExStyle & WS_EX_TOOLWINDOW)


Reply via email to