ReactOS 0.4.15-dev-7842-g558ab78
fileextractdialog.c File Reference
#include "precomp.h"
#include <wingdi.h>
#include <commdlg.h>
#include <shlobj.h>
#include "fileextractdialog.h"
#include "comctl32supp.h"
#include "utils.h"
Include dependency graph for fileextractdialog.c:

Go to the source code of this file.

Functions

VOID AddStringToComboList (HWND hWnd, LPCWSTR lpszString)
 
INT_PTR CALLBACK FileExtractDialogWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ AddStringToComboList()

VOID AddStringToComboList ( HWND  hWnd,
LPCWSTR  lpszString 
)

Definition at line 34 of file fileextractdialog.c.

36{
37 /* Try to find an already existing occurrence of the string in the list */
38 LRESULT hPos = ComboBox_FindStringExact(hWnd, -1, lpszString);
39
40 if (hPos == CB_ERR)
41 {
42 /* The string doesn't exist, so add it to the list and select it */
43 ComboBox_InsertString(hWnd, 0, lpszString);
45 }
46 else
47 {
48 /* The string exists, so select it */
50 }
51
52 return;
53}
HWND hWnd
Definition: settings.c:17
LONG_PTR LRESULT
Definition: windef.h:209
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:66
#define ComboBox_InsertString(hwndCtl, index, lpsz)
Definition: windowsx.h:61
#define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:47
#define CB_ERR
Definition: winuser.h:2435

Referenced by FileExtractDialogWndProc().

◆ FileExtractDialogWndProc()

INT_PTR CALLBACK FileExtractDialogWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 56 of file fileextractdialog.c.

60{
62
63 switch (message)
64 {
65 case WM_INITDIALOG:
66 return TRUE;
67
68 case WM_COMMAND:
69 {
70 switch (LOWORD(wParam))
71 {
72 case IDOK:
73 {
74 LPWSTR szCabPathFileName, szFileName, szDestDir;
75 size_t cabPathNum, fileNameNum, destDirNum;
76
77 cabPathNum = GetWindowTextLengthW(GetDlgItem(hDlg, IDC_DRP_CAB_FILE)) + 1;
78 szCabPathFileName = (LPWSTR)MemAlloc(0, cabPathNum * sizeof(WCHAR));
79 GetDlgItemText(hDlg, IDC_DRP_CAB_FILE, szCabPathFileName, (int)cabPathNum);
80
82 szFileName = (LPWSTR)MemAlloc(0, fileNameNum * sizeof(WCHAR));
83 GetDlgItemText(hDlg, IDC_TXT_FILE_TO_RESTORE, szFileName, (int)fileNameNum);
84
85 destDirNum = GetWindowTextLengthW(GetDlgItem(hDlg, IDC_DRP_DEST_DIR)) + 1;
86 szDestDir = (LPWSTR)MemAlloc(0, destDirNum * sizeof(WCHAR));
87 GetDlgItemText(hDlg, IDC_DRP_DEST_DIR, szDestDir, (int)destDirNum);
88
89#if 0
90 if (!ExtractFromCabinet(szCabPathFileName, szFileName, szDestDir))
91 {
92 MessageBoxW(NULL, L"An error has occurred!!", L"Error", MB_ICONERROR | MB_OK);
93 }
94 else
95 {
96 MessageBoxW(NULL, L"All the files were uncompressed successfully.", L"Info", MB_ICONINFORMATION | MB_OK);
97
98 // TODO: Save the extraction paths into the registry.
99
100 /* Quit */
101 EndDialog(hDlg, LOWORD(wParam));
102 }
103#else
104 MessageBoxW(NULL, L"File extraction is unimplemented!", L"Info", MB_ICONINFORMATION | MB_OK);
105#endif
106
107 MemFree(szDestDir);
108 MemFree(szFileName);
109 MemFree(szCabPathFileName);
110
111 return TRUE;
112 }
113
114 case IDCANCEL:
115 EndDialog(hDlg, LOWORD(wParam));
116 return TRUE;
117
119 {
120 unsigned int nMaxFilesNum = 255;
121 size_t newSize = (nMaxFilesNum * (MAX_PATH + 1)) + 1;
122 LPWSTR szPath = (LPWSTR)MemAlloc(HEAP_ZERO_MEMORY, newSize * sizeof(WCHAR));
124
125 SecureZeroMemory(&ofn, sizeof(ofn));
126 ofn.lStructSize = sizeof(ofn);
127 ofn.hwndOwner = hDlg;
128 ofn.lpstrTitle = L"Files to be restored"; // L"Fichiers à restaurer"; // FIXME: Localize!
130 // ofn.FlagsEx = OFN_EX_NOPLACESBAR;
131 ofn.lpstrFilter = L"All files (*.*)\0*.*\0";
132 ofn.nFilterIndex = 0;
134 ofn.nMaxFile = (DWORD)newSize; // TODO: size_t to DWORD conversion...
135
136 if (GetSaveFileName(&ofn))
137 {
138 if ( (ofn.Flags & OFN_EXPLORER) &&
139 (ofn.Flags & OFN_ALLOWMULTISELECT) ) // Must be always true...
140 {
141 LPWSTR lpszFiles = szPath + ofn.nFileOffset;
142 LPWSTR lpszFilePatterns = NULL;
143
144 LPWSTR lpszTmp = lpszFiles;
145 unsigned int n = 0;
146 size_t numOfChars = 0;
147
148 /* Truncate the path, if needed */
149 szPath[ofn.nFileOffset - 1] = L'\0';
150
151 while (*lpszTmp)
152 {
153 ++n;
154 numOfChars += wcslen(lpszTmp)+1 + 3; // 3 = 2 quotation marks + 1 space.
155 lpszTmp += wcslen(lpszTmp)+1;
156 }
157
158 lpszFilePatterns = (LPWSTR)MemAlloc(HEAP_ZERO_MEMORY, numOfChars*sizeof(WCHAR));
159
160 if (n >= 2)
161 {
162 while (*lpszFiles)
163 {
164 wcscat(lpszFilePatterns, L"\"");
165 wcscat(lpszFilePatterns, lpszFiles);
166 wcscat(lpszFilePatterns, L"\"");
167
168 lpszFiles += wcslen(lpszFiles)+1;
169 if (*lpszFiles)
170 wcscat(lpszFilePatterns, L" ");
171 }
172 }
173 else
174 {
175 wcscpy(lpszFilePatterns, lpszFiles);
176 }
177
178 Edit_SetText(GetDlgItem(hDlg, IDC_TXT_FILE_TO_RESTORE), lpszFilePatterns);
180
183
184 MemFree(lpszFilePatterns);
185 }
186 }
187
189
190 break;
191 }
192
194 {
196 WCHAR szPath[MAX_PATH] = L"";
197
198 SecureZeroMemory(&ofn, sizeof(ofn));
199 ofn.lStructSize = sizeof(ofn);
200 ofn.hwndOwner = hDlg;
201 ofn.lpstrTitle = L"Open an archive file"; // L"Ouvrir un fichier archive"; // FIXME: Localize!
203 // ofn.FlagsEx = OFN_EX_NOPLACESBAR;
204 ofn.lpstrFilter = L"Cabinet files (*.cab)\0*.cab\0";
205 ofn.lpstrDefExt = L"cab";
206 ofn.nFilterIndex = 0;
209
210 if (GetOpenFileName(&ofn))
211 {
214 }
215
216 break;
217 }
218
220 {
221 BROWSEINFOW bi;
222 WCHAR szPath[MAX_PATH] = L"";
223
224 SecureZeroMemory(&bi, sizeof(bi));
225 bi.hwndOwner = hDlg;
226 bi.pidlRoot = NULL;
227 bi.lpszTitle = L"Select the directory where the restored files should be stored:";
228 // L"Choisissez le répertoire dans lequel doivent être enregistrés les fichiers restaurés :"; // FIXME: Localize!
229 bi.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE | BIF_VALIDATE /* | BIF_BROWSEFILEJUNCTIONS <--- only in Windows 7+ */;
230
232 {
233 /*PIDLIST_ABSOLUTE*/ LPITEMIDLIST pidl = SHBrowseForFolderW(&bi);
234 if (SHGetPathFromIDListW(pidl, szPath))
235 {
238 }
239
240 CoTaskMemFree(pidl);
242 }
243
244 break;
245 }
246
247 default:
248 //break;
249 return FALSE;
250 }
251 }
252 }
253
254 return FALSE;
255}
#define IDC_BTN_BROWSE_CAB_FILES
Definition: resource.h:93
#define IDC_BTN_BROWSE_ALL_FILES
Definition: resource.h:92
#define IDC_DRP_DEST_DIR
Definition: resource.h:97
#define IDC_TXT_FILE_TO_RESTORE
Definition: resource.h:95
#define IDC_DRP_CAB_FILE
Definition: resource.h:96
#define IDC_BTN_BROWSE_DIRS
Definition: resource.h:94
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
PVOID MemAlloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: utils.c:33
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_LONGNAMES
Definition: commdlg.h:108
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_READONLY
Definition: commdlg.h:118
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetOpenFileName
Definition: commdlg.h:665
#define OFN_ALLOWMULTISELECT
Definition: commdlg.h:96
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1419
VOID AddStringToComboList(HWND hWnd, LPCWSTR lpszString)
GLdouble n
Definition: glext.h:7729
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
LPCWSTR szPath
Definition: env.c:37
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1344
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define BIF_VALIDATE
Definition: shlobj.h:1215
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1210
#define BIF_USENEWUI
Definition: shlobj.h:1217
#define BIF_SHAREABLE
Definition: shlobj.h:1226
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
OPENFILENAME ofn
Definition: sndrec32.cpp:56
Definition: tftpd.h:60
PCIDLIST_ABSOLUTE pidlRoot
Definition: shlobj.h:1194
UINT ulFlags
Definition: shlobj.h:1197
HWND hwndOwner
Definition: shlobj.h:1193
LPCWSTR lpszTitle
Definition: shlobj.h:1196
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nFilterIndex
Definition: commdlg.h:335
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
WORD nFileOffset
Definition: commdlg.h:343
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define SecureZeroMemory
Definition: winbase.h:1713
#define Edit_SetSel(hwndCtl, ichStart, ichEnd)
Definition: windowsx.h:110
#define Edit_SetText(hwndCtl, lpsz)
Definition: windowsx.h:112
#define IDCANCEL
Definition: winuser.h:831
#define GetDlgItemText
Definition: winuser.h:5785
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define MB_ICONERROR
Definition: winuser.h:787
HWND WINAPI SetFocus(_In_opt_ HWND)
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MB_OK
Definition: winuser.h:790
#define MB_ICONINFORMATION
Definition: winuser.h:802
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GeneralPageWndProc().