Copy rpoolmgr.h from trunk
[reactos.git] / rosapps / winfile / dialogs.c
1 /*
2 * ReactOS winfile
3 *
4 * dialogs.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
24 #include <windows.h>
25 #include <commctrl.h>
26 #include <stdlib.h>
27 #include <malloc.h>
28 #include <memory.h>
29 #include <tchar.h>
30 #include <process.h>
31 #include <stdio.h>
32
33 #include <shellapi.h>
34 //#include <winspool.h>
35 #include <windowsx.h>
36 #include <shellapi.h>
37 #include <ctype.h>
38 #include <assert.h>
39 #define ASSERT assert
40
41 #include "main.h"
42 #include "about.h"
43 #include "dialogs.h"
44 #include "settings.h"
45 #include "utils.h"
46 #include "debug.h"
47
48
49 BOOL CALLBACK ExecuteDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
50 {
51 static struct ExecuteDialog* dlg;
52
53 switch(message) {
54 case WM_INITDIALOG:
55 dlg = (struct ExecuteDialog*) lParam;
56 return 1;
57
58 case WM_COMMAND: {
59 int id = (int)wParam;
60
61 if (id == IDOK) {
62 GetWindowText(GetDlgItem(hDlg, 201), dlg->cmd, MAX_PATH);
63 dlg->cmdshow = Button_GetState(GetDlgItem(hDlg,214))&BST_CHECKED?
64 SW_SHOWMINIMIZED: SW_SHOWNORMAL;
65 EndDialog(hDlg, id);
66 } else if (id == IDCANCEL)
67 EndDialog(hDlg, id);
68
69 return 1;}
70 }
71
72 return 0;
73 }
74
75
76 BOOL CALLBACK OptionsConfirmationWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
77 {
78 static struct ExecuteDialog* dlg;
79 int id;
80
81 switch (message) {
82 case WM_INITDIALOG:
83 dlg = (struct ExecuteDialog*) lParam;
84 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_FILE_DELETE), Confirmation & CONFIRM_FILE_DELETE ? BST_CHECKED : BST_UNCHECKED);
85 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_DIR_DELETE), Confirmation & CONFIRM_DIR_DELETE ? BST_CHECKED : BST_UNCHECKED);
86 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_FILE_REPLACE), Confirmation & CONFIRM_FILE_REPLACE ? BST_CHECKED : BST_UNCHECKED);
87 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_MOUSE_ACTIONS), Confirmation & CONFIRM_MOUSE_ACTIONS ? BST_CHECKED : BST_UNCHECKED);
88 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_DISK_COMMANDS), Confirmation & CONFIRM_DISK_COMMANDS ? BST_CHECKED : BST_UNCHECKED);
89 Button_SetCheck(GetDlgItem(hDlg,IDC_CONFIRMATION_MODIFY_SYSTEM), Confirmation & CONFIRM_MODIFY_SYSTEM ? BST_CHECKED : BST_UNCHECKED);
90 return 1;
91 case WM_COMMAND:
92 id = (int)wParam;
93 if (id == IDOK) {
94 GetWindowText(GetDlgItem(hDlg, 201), dlg->cmd, MAX_PATH);
95 dlg->cmdshow = Button_GetState(GetDlgItem(hDlg,214))&BST_CHECKED?SW_SHOWMINIMIZED: SW_SHOWNORMAL;
96
97 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_FILE_DELETE)) & BST_CHECKED)
98 Confirmation |= CONFIRM_FILE_DELETE;
99 else Confirmation &= ~CONFIRM_FILE_DELETE;
100 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_DIR_DELETE)) & BST_CHECKED)
101 Confirmation |= CONFIRM_DIR_DELETE;
102 else Confirmation &= ~CONFIRM_DIR_DELETE;
103 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_FILE_REPLACE)) & BST_CHECKED)
104 Confirmation |= CONFIRM_FILE_REPLACE;
105 else Confirmation &= ~CONFIRM_FILE_REPLACE;
106 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_MOUSE_ACTIONS)) & BST_CHECKED)
107 Confirmation |= CONFIRM_MOUSE_ACTIONS;
108 else Confirmation &= ~CONFIRM_MOUSE_ACTIONS;
109 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_DISK_COMMANDS)) & BST_CHECKED)
110 Confirmation |= CONFIRM_DISK_COMMANDS;
111 else Confirmation &= ~CONFIRM_DISK_COMMANDS;
112 if (Button_GetState(GetDlgItem(hDlg,IDC_CONFIRMATION_MODIFY_SYSTEM)) & BST_CHECKED)
113 Confirmation |= CONFIRM_MODIFY_SYSTEM;
114 else Confirmation &= ~CONFIRM_MODIFY_SYSTEM;
115
116 EndDialog(hDlg, id);
117 } else if (id == IDCANCEL)
118 EndDialog(hDlg, id);
119 return 1;
120 }
121 return 0;
122 }
123
124
125 BOOL CALLBACK ViewFileTypeWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
126 {
127 static struct ExecuteDialog* dlg;
128 int id;
129
130 switch (message) {
131 case WM_INITDIALOG:
132 dlg = (struct ExecuteDialog*)lParam;
133 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_DIRECTORIES), ViewType & VIEW_DIRECTORIES ? BST_CHECKED : BST_UNCHECKED);
134 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_PROGRAMS), ViewType & VIEW_PROGRAMS ? BST_CHECKED : BST_UNCHECKED);
135 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_DOCUMENTS), ViewType & VIEW_DOCUMENTS ? BST_CHECKED : BST_UNCHECKED);
136 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_OTHERS), ViewType & VIEW_OTHER ? BST_CHECKED : BST_UNCHECKED);
137 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_SYSFILES), ViewType & VIEW_SYSTEM ? BST_CHECKED : BST_UNCHECKED);
138 return 1;
139 case WM_COMMAND:
140 id = (int)wParam;
141 if (id == IDOK) {
142 GetWindowText(GetDlgItem(hDlg, 201), dlg->cmd, MAX_PATH);
143 dlg->cmdshow = Button_GetState(GetDlgItem(hDlg,214))&BST_CHECKED?SW_SHOWMINIMIZED: SW_SHOWNORMAL;
144
145 if (Button_GetState(GetDlgItem(hDlg,IDC_VIEW_TYPE_DIRECTORIES)) & BST_CHECKED)
146 ViewType |= VIEW_DIRECTORIES;
147 else ViewType &= ~VIEW_DIRECTORIES;
148 if (Button_GetState(GetDlgItem(hDlg,IDC_VIEW_TYPE_PROGRAMS)) & BST_CHECKED)
149 ViewType |= VIEW_PROGRAMS;
150 else ViewType &= ~VIEW_PROGRAMS;
151 if (Button_GetState(GetDlgItem(hDlg,IDC_VIEW_TYPE_DOCUMENTS)) & BST_CHECKED)
152 ViewType |= VIEW_DOCUMENTS;
153 else ViewType &= ~VIEW_DOCUMENTS;
154 if (Button_GetState(GetDlgItem(hDlg,IDC_VIEW_TYPE_OTHERS)) & BST_CHECKED)
155 ViewType |= VIEW_OTHER;
156 else ViewType &= ~VIEW_OTHER;
157 if (Button_GetState(GetDlgItem(hDlg,IDC_VIEW_TYPE_SYSFILES)) & BST_CHECKED)
158 ViewType |= VIEW_SYSTEM;
159 else ViewType &= ~VIEW_SYSTEM;
160 EndDialog(hDlg, id);
161 } else if (id == IDCANCEL)
162 EndDialog(hDlg, id);
163 return 1;
164 }
165 return 0;
166 }
167
168 ////////////////////////////////////////////////////////////////////////////////
169 /*
170 TotalFileSize [in] Specifies the total size of the file, in bytes.
171 TotalBytesTransferred [in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
172 StreamSize [in] Specifies the total size of the current file stream, in bytes.
173 StreamBytesTransferred [in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
174 dwStreamNumber [in] Handle to the current stream. The stream number is 1 the first time CopyProgressRoutine is called.
175 dwCallbackReason [in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values. Value Meaning
176 CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
177 CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.
178 hSourceFile [in] Handle to the source file.
179 hDestinationFile [in] Handle to the destination file
180 lpData [in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.
181
182 Return Values The CopyProgressRoutine function should return one of the following values.
183 Value Meaning
184 PROGRESS_CONTINUE Continue the copy operation.
185 PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
186 PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
187 PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.
188 */
189 DWORD CALLBACK CopyProgressRoutine(
190 LARGE_INTEGER TotalFileSize, // file size
191 LARGE_INTEGER TotalBytesTransferred, // bytes transferred
192 LARGE_INTEGER StreamSize, // bytes in stream
193 LARGE_INTEGER StreamBytesTransferred, // bytes transferred for stream
194 DWORD dwStreamNumber, // current stream
195 DWORD dwCallbackReason, // callback reason
196 HANDLE hSourceFile, // handle to source file
197 HANDLE hDestinationFile, // handle to destination file
198 LPVOID lpData // from CopyFileEx
199 )
200 {
201 return 0L;
202 }
203
204 BOOL CALLBACK MoveFileWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
205 {
206 static struct ExecuteDialog* dlg;
207 int id;
208 TCHAR buffer_from[1000];
209 TCHAR buffer_to[1000];
210
211 switch (message) {
212 case WM_INITDIALOG:
213 dlg = (struct ExecuteDialog*)lParam;
214
215 _tcscpy(buffer_from, _T("C:\\TEMP\\API_SPY\\TEMP\\foobar.txt"));
216 SetDlgItemText(hDlg, IDC_FILE_MOVE_FROM, buffer_from);
217 _tcscpy(buffer_to, _T("C:\\TEMP\\API_SPY\\TEMP\\foobar2.txt"));
218 SetDlgItemText(hDlg, IDC_FILE_MOVE_TO, buffer_to);
219 /*
220 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_DIRECTORIES), ViewType & VIEW_DIRECTORIES ? BST_CHECKED : BST_UNCHECKED);
221 */
222 return 1;
223 case WM_COMMAND:
224 id = (int)wParam;
225 if (id == IDOK) {
226 LPVOID lpData = NULL; // parameter for callback
227 DWORD dwFlags = MOVEFILE_COPY_ALLOWED; // move options
228
229 GetDlgItemText(hDlg, IDC_FILE_MOVE_FROM, buffer_from, sizeof(buffer_from)/sizeof(TCHAR));
230 GetDlgItemText(hDlg, IDC_FILE_MOVE_TO, buffer_to, sizeof(buffer_to)/sizeof(TCHAR));
231 /*
232 BOOL MoveFileWithProgress(
233 LPCTSTR lpExistingFileName, // file name
234 LPCTSTR lpNewFileName, // new file name
235 LPPROGRESS_ROUTINE lpProgressRoutine, // callback function
236 LPVOID lpData, // parameter for callback
237 DWORD dwFlags // move options
238 );
239 */
240 // if (!MoveFileWithProgress(buffer_from, buffer_to, &CopyProgressRoutine, lpData, dwFlags)) {
241 if (!MoveFileEx(buffer_from, buffer_to, dwFlags)) {
242 DWORD err = GetLastError();
243 HLOCAL hMem;
244 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (LPTSTR)&hMem, 10, NULL)) {
245 MessageBox(hDlg, hMem, szTitle, MB_OK);
246 LocalFree(hMem);
247 } else {
248 MessageBox(hDlg, _T("Unknown Error"), szTitle, MB_OK);
249 }
250 }
251
252 EndDialog(hDlg, id);
253 } else if (id == IDCANCEL)
254 EndDialog(hDlg, id);
255 return 1;
256 }
257 return 0;
258 }
259
260
261 /*
262 extern TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN];
263 */
264
265 void ShowFixedFileInfo(HWND hDlg, VS_FIXEDFILEINFO* pFixedFileInfo)
266 {
267 TCHAR* str = NULL;
268
269 switch (pFixedFileInfo->dwFileType) {
270 case VFT_UNKNOWN: str = _T("The file type is unknown to the system."); break;
271 case VFT_APP: str = _T("The file contains an application."); break;
272 case VFT_DLL: str = _T("The file contains a dynamic-link library (DLL)."); break;
273 case VFT_DRV:
274 str = _T("The file contains a device driver. If dwFileType is VFT_DRV, dwFileSubtype contains a more specific description of the driver.");
275 switch (pFixedFileInfo->dwFileSubtype) {
276 case VFT2_UNKNOWN: str = _T("The driver type is unknown by the system."); break;
277 case VFT2_DRV_COMM: str = _T("The file contains a communications driver."); break;
278 case VFT2_DRV_PRINTER: str = _T("The file contains a printer driver."); break;
279 case VFT2_DRV_KEYBOARD: str = _T("The file contains a keyboard driver"); break;
280 case VFT2_DRV_LANGUAGE: str = _T("The file contains a language driver"); break;
281 case VFT2_DRV_DISPLAY: str = _T("The file contains a display driver"); break;
282 case VFT2_DRV_MOUSE: str = _T("The file contains a mouse driver"); break;
283 case VFT2_DRV_NETWORK: str = _T("The file contains a network driver"); break;
284 case VFT2_DRV_SYSTEM: str = _T("The file contains a system driver"); break;
285 case VFT2_DRV_INSTALLABLE: str = _T("The file contains an installable driver"); break;
286 case VFT2_DRV_SOUND: str = _T("The file contains a sound driver"); break;
287 }
288 break;
289 case VFT_FONT:
290 str = _T("The file contains a font. If dwFileType is VFT_FONT, dwFileSubtype contains a more specific description of the font file.");
291 switch (pFixedFileInfo->dwFileSubtype) {
292 case VFT2_UNKNOWN: str = _T("The font type is unknown the system."); break;
293 case VFT2_FONT_RASTER: str = _T("The file contains a raster font."); break;
294 case VFT2_FONT_VECTOR: str = _T("The file contains a vector font."); break;
295 case VFT2_FONT_TRUETYPE: str = _T("The file contains a TrueType font."); break;
296
297 }
298 break;
299 case VFT_VXD: str = _T("The file contains a virtual device."); break;
300 case VFT_STATIC_LIB: str = _T("The file contains a static-link library."); break;
301 }
302 if (str != NULL) {
303 SetDlgItemText(hDlg, IDC_STATIC_PROP_VERSION, str);
304 // SetDlgItemText(hDlg, IDC_STATIC_PROP_COPYRIGHT, pVersionData);
305 }
306 }
307
308 // Structure used to store enumerated languages and code pages.
309 struct LANGANDCODEPAGE {
310 WORD wLanguage;
311 WORD wCodePage;
312 } *lpTranslate;
313
314 void AddFileInfoValue(HWND hDlg, void* pVersionData, struct LANGANDCODEPAGE lpTranslate, UINT i, LPCTSTR info_str)
315 {
316 TCHAR SubBlock[200];
317 TCHAR* pVal;
318 UINT nValLen;
319
320 wsprintf(SubBlock, TEXT("\\StringFileInfo\\%04x%04x\\%s"),
321 lpTranslate.wLanguage, lpTranslate.wCodePage, info_str);
322 // Retrieve file description for language and code page "i".
323 if (VerQueryValue(pVersionData, SubBlock, (PVOID)&pVal, &nValLen)) {
324 ListBox_InsertItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), i, info_str);
325 // ListBox_InsertItemData(pane->hwnd, idx, entry);
326 SendMessage(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_VALUES), WM_SETTEXT, 0, (LPARAM)pVal);
327 }
328 }
329
330 static TCHAR* InfoStrings[] = {
331 TEXT("Comments"),
332 TEXT("InternalName"),
333 TEXT("ProductName"),
334 TEXT("CompanyName"),
335 TEXT("LegalCopyright"),
336 TEXT("ProductVersion"),
337 TEXT("FileDescription"),
338 TEXT("LegalTrademarks"),
339 TEXT("PrivateBuild"),
340 TEXT("FileVersion"),
341 TEXT("OriginalFilename"),
342 TEXT("SpecialBuild"),
343 TEXT(""),
344 NULL
345 };
346
347 void SelectVersionString(HWND hDlg, LPARAM lParam)
348 {
349 int idx;
350
351 // idx = ListBox_FindItemData(hwnd, , child->left.cur);
352 idx = ListBox_GetCurSel(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES));
353
354 //Entry* entry = (Entry*) ListBox_GetItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), idx);
355
356 // SendMessage(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_VALUES), WM_SETTEXT, 0, (LPARAM)pVal);
357
358 // ListBox_SetCurSel(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), idx);
359
360 // ListBox_InsertItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), i, _T("FileDescription"));
361 // SendMessage(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_VALUES), WM_SETTEXT, 0, pVal);
362
363 }
364
365 void CheckForFileInfo(HWND hDlg, TCHAR* strFilename)
366 {
367 TCHAR SubBlock[200];
368 UINT i;
369 DWORD dwHandle;
370 DWORD dwVersionDataLen = GetFileVersionInfoSize(strFilename, &dwHandle);
371 if (dwVersionDataLen != 0L) {
372 void* pVersionData = malloc(dwVersionDataLen);
373 if (GetFileVersionInfo(strFilename, 0, dwVersionDataLen, pVersionData)) {
374 TCHAR* pVal;
375 UINT nValLen;
376 // LPTSTR SubBlock = _T("\\");
377 _tcscpy(SubBlock, TEXT("\\"));
378 if (VerQueryValue(pVersionData, SubBlock, (PVOID)&pVal, &nValLen)) {
379 if (nValLen == sizeof(VS_FIXEDFILEINFO)) {
380 ShowFixedFileInfo(hDlg, (VS_FIXEDFILEINFO*)pVal);
381 }
382 }
383 #if 1
384 {
385
386 // Read the list of languages and code pages.
387 _tcscpy(SubBlock, TEXT("\\VarFileInfo\\Translation"));
388 if (VerQueryValue(pVersionData, SubBlock, (LPVOID*)&pVal, &nValLen)) {
389 // Read the file description for each language and code page.
390 for (i = 0; i < (nValLen/sizeof(struct LANGANDCODEPAGE)); i++) {
391 int j = 0;
392 TCHAR* pInfoString;
393 while (pInfoString = InfoStrings[j]) {
394 if (pInfoString != NULL && _tcslen(pInfoString)) {
395 struct LANGANDCODEPAGE* lpTranslate = (struct LANGANDCODEPAGE*)pVal;
396 AddFileInfoValue(hDlg, pVersionData, lpTranslate[i],
397 j, pInfoString);
398 }
399 ++j;
400 }
401 // lpTranslate = (struct LANGANDCODEPAGE*)pVal;
402 /*
403 wsprintf(SubBlock, TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
404 lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);
405 // Retrieve file description for language and code page "i".
406 if (VerQueryValue(pVersionData, SubBlock, &pVal, &nValLen)) {
407 ListBox_InsertItemData(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_TYPES), i, _T("FileDescription"));
408 SendMessage(GetDlgItem(hDlg, IDC_LIST_PROP_VERSION_VALUES), WM_SETTEXT, 0, pVal);
409 }
410 */
411 }
412 }
413 }
414 #endif
415 }
416 free(pVersionData);
417 }
418 }
419
420 BOOL CALLBACK PropertiesDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
421 {
422 static struct PropertiesDialog* dlg;
423 SYSTEMTIME SystemTime;
424 FILETIME LocalFileTime;
425 TCHAR buffer[MAX_PATH];
426 TCHAR text[100];
427 int id;
428 int offset;
429 DWORD dwFileAttributes;
430 Entry* entry;
431
432 switch (message) {
433 case WM_INITDIALOG:
434 dlg = (struct PropertiesDialog*)lParam;
435 ASSERT(dlg);
436 entry = ((struct PropertiesDialog*)lParam)->pEntry;
437 ASSERT(entry);
438
439 GetWindowText(hDlg, text, sizeof(text)/sizeof(TCHAR));
440 wsprintf(buffer, text, dlg->pEntry->data.cFileName);
441 SetWindowText(hDlg, buffer);
442 SetDlgItemText(hDlg, IDC_STATIC_PROP_FILENAME, dlg->pEntry->data.cFileName);
443 SetDlgItemText(hDlg, IDC_STATIC_PROP_PATH, dlg->pEntry->data.cAlternateFileName);
444
445 if (entry->bhfi_valid) {
446 NUMBERFMT numFmt;
447 memset(&numFmt, 0, sizeof(numFmt));
448 numFmt.NumDigits = 0;
449 numFmt.LeadingZero = 0;
450 numFmt.Grouping = 3;
451 numFmt.lpDecimalSep = _T(".");
452 numFmt.lpThousandSep = _T(",");
453 numFmt.NegativeOrder = 0;
454
455 //entry->bhfi.nFileSizeLow;
456 //entry->bhfi.nFileSizeHigh;
457 //entry->bhfi.ftCreationTime
458 wsprintf(buffer, _T("%u"), entry->bhfi.nFileSizeLow);
459 if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, buffer, &numFmt,
460 buffer + MAX_PATH/2, MAX_PATH/2)) {
461 SetDlgItemText(hDlg, IDC_STATIC_PROP_SIZE, buffer + MAX_PATH/2);
462 } else {
463 SetDlgItemText(hDlg, IDC_STATIC_PROP_SIZE, buffer);
464 }
465 } else {
466 }
467
468 SetDlgItemText(hDlg, IDC_STATIC_PROP_LASTCHANGE, _T("Date?"));
469 if (FileTimeToLocalFileTime(&entry->bhfi.ftLastWriteTime, &LocalFileTime)) {
470 if (FileTimeToSystemTime(&LocalFileTime, &SystemTime)) {
471 if (GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &SystemTime, NULL, buffer, sizeof(buffer)/sizeof(TCHAR))) {
472 // SetDlgItemText(hDlg, IDC_STATIC_PROP_LASTCHANGE, buffer);
473 }
474 }
475 }
476 _tcscat(buffer, _T(" "));
477 offset = _tcslen(buffer);
478
479 if (FileTimeToLocalFileTime(&entry->bhfi.ftLastWriteTime, &LocalFileTime)) {
480 if (FileTimeToSystemTime(&LocalFileTime, &SystemTime)) {
481 if (GetTimeFormat(LOCALE_USER_DEFAULT, 0, &SystemTime, NULL, buffer + offset, sizeof(buffer)/sizeof(TCHAR) - offset)) {
482 SetDlgItemText(hDlg, IDC_STATIC_PROP_LASTCHANGE, buffer);
483 }
484 }
485 }
486
487 dwFileAttributes = dlg->pEntry->bhfi.dwFileAttributes;
488 Button_SetCheck(GetDlgItem(hDlg,IDC_CHECK_READONLY), dwFileAttributes & FILE_ATTRIBUTE_READONLY ? BST_CHECKED : BST_UNCHECKED);
489 Button_SetCheck(GetDlgItem(hDlg,IDC_CHECK_ARCHIVE), dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE ? BST_CHECKED : BST_UNCHECKED);
490 Button_SetCheck(GetDlgItem(hDlg,IDC_CHECK_COMPRESSED), dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED ? BST_CHECKED : BST_UNCHECKED);
491 Button_SetCheck(GetDlgItem(hDlg,IDC_CHECK_HIDDEN), dwFileAttributes & FILE_ATTRIBUTE_HIDDEN ? BST_CHECKED : BST_UNCHECKED);
492 Button_SetCheck(GetDlgItem(hDlg,IDC_CHECK_SYSTEM), dwFileAttributes & FILE_ATTRIBUTE_SYSTEM ? BST_CHECKED : BST_UNCHECKED);
493
494 CheckForFileInfo(hDlg, dlg->pEntry->data.cFileName);
495 return 1;
496
497 case WM_COMMAND:
498 id = (int)wParam;
499 if (id == IDOK) {
500 // LPVOID lpData = NULL; // parameter for callback
501 // DWORD dwFlags = MOVEFILE_COPY_ALLOWED; // move options
502 // GetDlgItemText(hDlg, , buffer, sizeof(buffer)/sizeof(TCHAR));
503 // GetDlgItemText(hDlg, , buffer, sizeof(buffer)/sizeof(TCHAR));
504 EndDialog(hDlg, id);
505 } else if (id == IDCANCEL) {
506 EndDialog(hDlg, id);
507 } else {
508 switch(HIWORD(wParam)) {
509 case LBN_SELCHANGE:
510 if (LOWORD(wParam) == IDC_LIST_PROP_VERSION_TYPES) {
511 SelectVersionString(hDlg, lParam);
512 }
513 // {
514 // int idx = ListBox_GetCurSel(pane->hwnd);
515 // Entry* entry = (Entry*) ListBox_GetItemData(pane->hwnd, idx);
516 // if (pane == &child->left) set_curdir(child, entry);
517 // else pane->cur = entry;
518 // }
519 break;
520 case LBN_DBLCLK:
521 //activate_entry(child, pane);
522 break;
523 }
524 }
525 return 1;
526 }
527 return 0;
528 }