[RAPPS]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 13 Oct 2012 13:35:55 +0000 (13:35 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 13 Oct 2012 13:35:55 +0000 (13:35 +0000)
- Use COM for calling SHBrowseForFolder.
- Allow choosing a directory for downloading.
- Correct a typo in the name of a function.

svn path=/trunk/; revision=57553

reactos/base/applications/rapps/CMakeLists.txt
reactos/base/applications/rapps/rapps.h
reactos/base/applications/rapps/settingsdlg.c
reactos/base/applications/rapps/winmain.c

index 52d4f49..c0f933e 100644 (file)
@@ -29,7 +29,7 @@ add_pch(rapps rapps.h)
 set_module_type(rapps win32gui UNICODE)
 target_link_libraries(rapps uuid)
 
-add_importlibs(rapps advapi32 comctl32 gdi32 urlmon user32 shell32 shlwapi msvcrt kernel32 ntdll)
+add_importlibs(rapps advapi32 comctl32 gdi32 urlmon user32 shell32 shlwapi ole32 msvcrt kernel32 ntdll)
 add_dependencies(rapps rappsmsg)
 add_message_headers(ANSI rappsmsg.mc)
 add_cd_file(TARGET rapps DESTINATION reactos/system32 FOR all)
index 261813a..b56c65d 100644 (file)
@@ -115,7 +115,7 @@ extern HINSTANCE hInst;
 extern INT SelectedEnumType;
 extern SETTINGS_INFO SettingsInfo;
 VOID SaveSettings(HWND hwnd);
-VOID FillDafaultSettings(PSETTINGS_INFO pSettingsInfo);
+VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
 
 /* listview.c */
 extern HWND hListView;
index 77034c5..278bd3f 100644 (file)
@@ -6,6 +6,7 @@
  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
  */
 
+#define _WIN32_DCOM // For CoInitializeEx, etc...
 #include "rapps.h"
 
 SETTINGS_INFO NewSettingsInfo;
@@ -16,27 +17,35 @@ SETTINGS_INFO NewSettingsInfo;
 BOOL
 ChooseFolder(HWND hwnd)
 {
-    BROWSEINFO fi;
-    LPCITEMIDLIST lpItemList;
+    BOOL bRet = FALSE;
+    BROWSEINFO bi;
     WCHAR szPath[MAX_PATH], szBuf[MAX_STR_LEN];
 
     LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, sizeof(szBuf) / sizeof(TCHAR));
 
-    ZeroMemory(&fi, sizeof(BROWSEINFO));
-    fi.hwndOwner = hwnd;
-    fi.lpszTitle = szBuf;
-    fi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_BROWSEFORCOMPUTER | BIF_NEWDIALOGSTYLE;
-    fi.lpfn = NULL;
-    fi.lParam = -1;
-    fi.iImage = 0;
+    ZeroMemory(&bi, sizeof(bi));
+    bi.hwndOwner = hwnd;
+    bi.pidlRoot  = NULL;
+    bi.lpszTitle = szBuf;
+    bi.ulFlags   = BIF_USENEWUI | BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | /* BIF_BROWSEFILEJUNCTIONS | */ BIF_VALIDATE;
 
-    if (!(lpItemList = SHBrowseForFolder(&fi))) return FALSE;
-    SHGetPathFromIDList(lpItemList, szPath);
+    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
+    {
+        LPITEMIDLIST lpItemList = SHBrowseForFolder(&bi);
+        if (lpItemList && SHGetPathFromIDList(lpItemList, szPath))
+        {
+            if (szPath[0] != 0)
+            {
+                SetDlgItemTextW(hwnd, IDC_DOWNLOAD_DIR_EDIT, szPath);
+                bRet = TRUE;
+            }
+        }
 
-    if (wcslen(szPath) == 0) return FALSE;
-    SetDlgItemTextW(hwnd, IDC_DOWNLOAD_DIR_EDIT, szPath);
+        CoTaskMemFree(lpItemList);
+        CoUninitialize();
+    }
 
-    return TRUE;
+    return bRet;
 }
 
 static VOID
@@ -89,7 +98,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
                     break;
 
                 case IDC_DEFAULT_SETTINGS:
-                    FillDafaultSettings(&NewSettingsInfo);
+                    FillDefaultSettings(&NewSettingsInfo);
                     InitSettingsControls(hDlg, NewSettingsInfo);
                     break;
 
index 7a1f228..294b654 100644 (file)
@@ -16,7 +16,7 @@ SETTINGS_INFO SettingsInfo;
 
 
 VOID
-FillDafaultSettings(PSETTINGS_INFO pSettingsInfo)
+FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
 {
     pSettingsInfo->bSaveWndPos = TRUE;
     pSettingsInfo->bUpdateAtStart = FALSE;
@@ -782,7 +782,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
 
     if (!LoadSettings())
     {
-        FillDafaultSettings(&SettingsInfo);
+        FillDefaultSettings(&SettingsInfo);
     }
 
     InitLogs();