ReactOS  0.4.12-dev-14-gd0c8636
fileextractdialog.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

Function Documentation

◆ FileExtractDialogWndProc()

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

Definition at line 56 of file fileextractdialog.c.

Referenced by GeneralPageWndProc().

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;
133  ofn.lpstrFile = szPath;
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 
188  MemFree(szPath);
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;
207  ofn.lpstrFile = szPath;
208  ofn.nMaxFile = ARRAYSIZE(szPath);
209 
210  if (GetOpenFileName(&ofn))
211  {
214  }
215 
216  break;
217  }
218 
219  case IDC_BTN_BROWSE_DIRS:
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);
241  CoUninitialize();
242  }
243 
244  break;
245  }
246 
247  default:
248  //break;
249  return FALSE;
250  }
251  }
252  }
253 
254  return FALSE;
255 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
DWORD Flags
Definition: commdlg.h:373
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define OFN_LONGNAMES
Definition: commdlg.h:108
LPCWSTR lpstrFilter
Definition: commdlg.h:363
#define IDC_DRP_CAB_FILE
Definition: resource.h:96
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
#define SecureZeroMemory
Definition: winbase.h:1636
PVOID MemAlloc(IN DWORD dwFlags, IN DWORD dwBytes)
Definition: utils.c:33
LPWSTR lpstrFile
Definition: commdlg.h:367
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
OPENFILENAME ofn
Definition: main.cpp:37
HWND hwndOwner
Definition: shlobj.h:991
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define OFN_ALLOWMULTISELECT
Definition: commdlg.h:96
HWND WINAPI SetFocus(_In_opt_ HWND)
VOID AddStringToComboList(HWND hWnd, LPCWSTR lpszString)
#define IDC_TXT_FILE_TO_RESTORE
Definition: resource.h:95
#define GetOpenFileName
Definition: commdlg.h:665
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
DWORD lStructSize
Definition: commdlg.h:360
GLuint n
Definition: s_context.h:57
#define GetSaveFileName
Definition: commdlg.h:666
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
#define IDC_BTN_BROWSE_DIRS
Definition: resource.h:94
WORD nFileOffset
Definition: commdlg.h:374
smooth NULL
Definition: ftsmooth.c:416
#define IDC_BTN_BROWSE_CAB_FILES
Definition: resource.h:93
DWORD nFilterIndex
Definition: commdlg.h:366
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
LPCWSTR lpszTitle
Definition: shlobj.h:994
LPCITEMIDLIST pidlRoot
Definition: shlobj.h:992
#define GetDlgItemText
Definition: winuser.h:5651
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LPCWSTR lpstrTitle
Definition: commdlg.h:372
#define IDC_DRP_DEST_DIR
Definition: resource.h:97
#define MAX_PATH
Definition: compat.h:26
int WINAPI GetWindowTextLengthW(_In_ HWND)
DWORD nMaxFile
Definition: commdlg.h:368
#define BIF_USENEWUI
Definition: shlobj.h:1015
#define OFN_READONLY
Definition: commdlg.h:118
#define MB_ICONINFORMATION
Definition: winuser.h:796
HWND hwndOwner
Definition: commdlg.h:361
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
#define MB_ICONERROR
Definition: winuser.h:781
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define WM_COMMAND
Definition: winuser.h:1716
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1156
UINT ulFlags
Definition: shlobj.h:995
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1008
LPCWSTR szPath
Definition: env.c:35
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1994
#define Edit_SetSel(hwndCtl, ichStart, ichEnd)
Definition: windowsx.h:85
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1938
_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 MB_OK
Definition: winuser.h:784
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define IDC_BTN_BROWSE_ALL_FILES
Definition: resource.h:92
#define BIF_VALIDATE
Definition: shlobj.h:1013
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define Edit_SetText(hwndCtl, lpsz)
Definition: windowsx.h:87
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define BIF_SHAREABLE
Definition: shlobj.h:1024
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:57