[SHELL32] Add line bar to About dialog for consistence
[reactos.git] / dll / win32 / shell32 / wine / shell32_main.c
index 932ec2c..4ae3ea0 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright 1998 Marcus Meissner
  * Copyright 1998 Juergen Schmied (jsch)  *  <juergen.schmied@metronet.de>
+ * Copyright 2017 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -423,7 +424,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
 
     TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
           (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
-          psfi, psfi->dwAttributes, sizeofpsfi, flags);
+          psfi, psfi ? psfi->dwAttributes : 0, sizeofpsfi, flags);
 
     if (!path)
         return FALSE;
@@ -433,7 +434,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
     {
         psfi->szDisplayName[0] = '\0';
         psfi->szTypeName[0] = '\0';
-        psfi->iIcon = 0;
+        psfi->hIcon = NULL;
     }
 
     if (!(flags & SHGFI_PIDL))
@@ -449,12 +450,24 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
             lstrcpynW(szFullPath, path, MAX_PATH);
         }
     }
+    else
+    {
+        SHGetPathFromIDListW((LPITEMIDLIST)path, szFullPath);
+    }
 
     if (flags & SHGFI_EXETYPE)
     {
-        if (flags != SHGFI_EXETYPE)
-            return 0;
-        return shgfi_get_exe_type(szFullPath);
+        if (!(flags & SHGFI_SYSICONINDEX))
+        {
+            if (flags & SHGFI_USEFILEATTRIBUTES)
+            {
+                return TRUE;
+            }
+            else if (GetFileAttributesW(szFullPath) != INVALID_FILE_ATTRIBUTES)
+            {
+                return shgfi_get_exe_type(szFullPath);
+            }
+        }
     }
 
     /*
@@ -488,6 +501,8 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
                                 (LPCITEMIDLIST*)&pidlLast );
             if (SUCCEEDED(hr))
                 pidlLast = ILClone(pidlLast);
+            else
+                hr = S_OK;
             ILFree(pidl);
         }
         else
@@ -505,8 +520,18 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
             psfi->dwAttributes = 0xffffffff;
         }
         if (psfParent)
-            IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
-                                      &(psfi->dwAttributes) );
+        {
+            IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
+                                         &(psfi->dwAttributes));
+        }
+    }
+
+    if (flags & SHGFI_USEFILEATTRIBUTES)
+    {
+        if (flags & SHGFI_ICON)
+        {
+            psfi->dwAttributes = 0;
+        }
     }
 
     /* get the displayname */
@@ -516,7 +541,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
         {
             lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
         }
-        else
+        else if (psfParent)
         {
             STRRET str;
             hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
@@ -528,8 +553,9 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
     /* get the type name */
     if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
     {
+        static const WCHAR szFolder[] = { 'F','o','l','d','e','r',0 };
         static const WCHAR szFile[] = { 'F','i','l','e',0 };
-        static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
+        static const WCHAR szSpaceFile[] = { ' ','f','i','l','e',0 };
 
         if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL))
         {
@@ -541,17 +567,29 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
         else
         {
             if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
-                strcatW (psfi->szTypeName, szFile);
+                strcatW (psfi->szTypeName, szFolder);
             else 
             {
                 WCHAR sTemp[64];
 
                 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
-                if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
+                if (sTemp[0] == 0 || (sTemp[0] == '.' && sTemp[1] == 0))
+                {
+                    /* "name" or "name." => "File" */
+                    lstrcpynW (psfi->szTypeName, szFile, 64);
+                }
+                else if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
                     HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
                 {
-                    lstrcpynW (psfi->szTypeName, sTemp, 64);
-                    strcatW (psfi->szTypeName, szDashFile);
+                    if (sTemp[0])
+                    {
+                        lstrcpynW (psfi->szTypeName, sTemp, 64);
+                        strcatW (psfi->szTypeName, szSpaceFile);
+                    }
+                    else
+                    {
+                        lstrcpynW (psfi->szTypeName, szFile, 64);
+                    }
                 }
             }
         }
@@ -618,7 +656,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
                     ret = FALSE;
             }
         }
-        else
+        else if (psfParent)
         {
             hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
                 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
@@ -694,7 +732,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
                 }
             }
         }
-        else
+        else if (psfParent)
         {
             if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
                 uGilFlags, &(psfi->iIcon))))
@@ -723,6 +761,9 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
     if (flags & ~SHGFI_KNOWN_FLAGS)
         FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
 
+    if (psfParent)
+        IShellFolder_Release(psfParent);
+
     if (hr != S_OK)
         ret = FALSE;
 
@@ -766,33 +807,25 @@ DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
         pathW = temppath;
     }
 
-    if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
-        temppsfi.dwAttributes=psfi->dwAttributes;
+    if (psfi)
+    {
+        temppsfi.hIcon = psfi->hIcon;
+        temppsfi.iIcon = psfi->iIcon;
+        temppsfi.dwAttributes = psfi->dwAttributes;
 
-    if (psfi == NULL)
-        ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
-    else
         ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
+        psfi->hIcon = temppsfi.hIcon;
+        psfi->iIcon = temppsfi.iIcon;
+        psfi->dwAttributes = temppsfi.dwAttributes;
 
-    if (psfi)
-    {
-        if(flags & SHGFI_ICON)
-            psfi->hIcon=temppsfi.hIcon;
-        if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
-            psfi->iIcon=temppsfi.iIcon;
-        if(flags & SHGFI_ATTRIBUTES)
-            psfi->dwAttributes=temppsfi.dwAttributes;
-        if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
-        {
-            WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
-                  psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
-        }
-        if(flags & SHGFI_TYPENAME)
-        {
-            WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
-                  psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
-        }
+        WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
+              psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
+
+        WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
+              psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
     }
+    else
+        ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, 0, flags);
 
     HeapFree(GetProcessHeap(), 0, temppath);
 
@@ -1030,8 +1063,12 @@ HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
     TRACE("%s\n", debugstr_guid(rclsid));
 
     CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
-    if (ptr)
+    if(ptr)
+    {
+        IUnknown * pUnk = ptr;
+        IUnknown_Release(pUnk);
         return S_OK;
+    }
     return DISP_E_MEMBERNOTFOUND;
 }
 
@@ -1095,8 +1132,8 @@ INT_PTR CALLBACK AboutAuthorsDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
 static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
 {
     static DWORD   cxLogoBmp;
-    static DWORD   cyLogoBmp;
-    static HBITMAP hLogoBmp;
+    static DWORD   cyLogoBmp, cyLineBmp;
+    static HBITMAP hLogoBmp, hLineBmp;
     static HWND    hWndAuthors;
 
     switch(msg)
@@ -1116,8 +1153,9 @@ static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
 
                 // Preload the ROS bitmap
                 hLogoBmp = (HBITMAP)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_REACTOS), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+                hLineBmp = (HBITMAP)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDB_LINEBAR), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
 
-                if(hLogoBmp)
+                if(hLogoBmp && hLineBmp)
                 {
                     BITMAP bmpLogo;
 
@@ -1125,6 +1163,9 @@ static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
 
                     cxLogoBmp = bmpLogo.bmWidth;
                     cyLogoBmp = bmpLogo.bmHeight;
+
+                    GetObject( hLineBmp, sizeof(BITMAP), &bmpLogo );
+                    cyLineBmp = bmpLogo.bmHeight;
                 }
 
                 // Set App-specific stuff (icon, app name, szOtherStuff string)
@@ -1221,20 +1262,25 @@ static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM
 
         case WM_PAINT:
         {
-            if(hLogoBmp)
+            if(hLogoBmp && hLineBmp)
             {
                 PAINTSTRUCT ps;
                 HDC hdc;
                 HDC hdcMem;
+                HGDIOBJ hOldObj;
 
                 hdc = BeginPaint(hWnd, &ps);
                 hdcMem = CreateCompatibleDC(hdc);
 
                 if(hdcMem)
                 {
-                    SelectObject(hdcMem, hLogoBmp);
+                    hOldObj = SelectObject(hdcMem, hLogoBmp);
                     BitBlt(hdc, 0, 0, cxLogoBmp, cyLogoBmp, hdcMem, 0, 0, SRCCOPY);
 
+                    SelectObject(hdcMem, hLineBmp);
+                    BitBlt(hdc, 0, cyLogoBmp, cxLogoBmp, cyLineBmp, hdcMem, 0, 0, SRCCOPY);
+
+                    SelectObject(hdcMem, hOldObj);
                     DeleteDC(hdcMem);
                 }