From 97197150928f37ee58eabd163f885ebcc34aad12 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Thu, 2 Jun 2005 21:39:00 +0000 Subject: [PATCH] implemented file properties dialog (partly based on Rob D.'s winfile code) svn path=/trunk/; revision=15739 --- reactos/subsys/system/winefile/en.rc | 30 ++++ reactos/subsys/system/winefile/resource.h | 37 ++-- reactos/subsys/system/winefile/resource.rc | 1 + reactos/subsys/system/winefile/winefile.c | 190 +++++++++++++++++++- reactos/subsys/system/winefile/winefile.dsp | 8 +- reactos/subsys/system/winefile/winefile.xml | 1 + 6 files changed, 251 insertions(+), 16 deletions(-) diff --git a/reactos/subsys/system/winefile/en.rc b/reactos/subsys/system/winefile/en.rc index 7ec3d0e1742..834463fc098 100644 --- a/reactos/subsys/system/winefile/en.rc +++ b/reactos/subsys/system/winefile/en.rc @@ -201,6 +201,36 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,104,24,50,14 END +IDD_DIALOG_PROPERTIES DIALOG DISCARDABLE 0, 0, 248, 215 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Properties for %s" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,191,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,191,29,50,14 + LTEXT "&File Name:",-1,7,7,59,9 + EDITTEXT IDC_STATIC_PROP_FILENAME,71,7,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Full &Path:",-1,7,18,59,9 + EDITTEXT IDC_STATIC_PROP_PATH,71,18,120,9, ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Last Change:",-1,7,29,59,9 + EDITTEXT IDC_STATIC_PROP_LASTCHANGE,71,29,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Version:",-1,7,40,59,9 + EDITTEXT IDC_STATIC_PROP_VERSION,71,40,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Cop&yright:",-1,7,51,59,9 + EDITTEXT IDC_STATIC_PROP_COPYRIGHT,71,51,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Size:",-1,7,62,59,9 + EDITTEXT IDC_STATIC_PROP_SIZE,71,62,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + GROUPBOX "Attributes",-1,7,79,158,46 + GROUPBOX "&Version Information",-1,7,129,234,79 + CONTROL "&Read Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,91,68,9 + CONTROL "&Archive",IDC_CHECK_ARCHIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,68,9 + CONTROL "&Compressed",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9 + CONTROL "H&idden",IDC_CHECK_HIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,91,68,9 + CONTROL "&System",IDC_CHECK_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,101,68,9 + LISTBOX IDC_LIST_PROP_VERSION_TYPES,13,139,107,63,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_LIST_PROP_VERSION_VALUES,123,139,111,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL +END + STRINGTABLE { diff --git a/reactos/subsys/system/winefile/resource.h b/reactos/subsys/system/winefile/resource.h index a90329e7d14..3c1d1b771df 100644 --- a/reactos/subsys/system/winefile/resource.h +++ b/reactos/subsys/system/winefile/resource.h @@ -36,6 +36,7 @@ #define IDD_EXECUTE 103 #define IDD_SELECT_DESTINATION 104 #define IDD_DIALOG_VIEW_TYPE 105 +#define IDD_DIALOG_PROPERTIES 106 /* control ids */ @@ -43,21 +44,21 @@ #define ID_ACTIVATE 101 #define ID_EXECUTE 105 #define ID_FILE_MOVE 106 -#define ID_FILE_COPY 107 -#define ID_FILE_DELETE 108 +#define ID_FILE_COPY 107 +#define ID_FILE_DELETE 108 #define ID_FILE_EXIT 115 -#define ID_FORMAT_DISK 203 -#define ID_CONNECT_NETWORK_DRIVE 252 -#define ID_DISCONNECT_NETWORK_DRIVE 253 +#define ID_FORMAT_DISK 203 +#define ID_CONNECT_NETWORK_DRIVE 252 +#define ID_DISCONNECT_NETWORK_DRIVE 253 #define ID_VIEW_NAME 401 #define ID_VIEW_ALL_ATTRIBUTES 402 #define ID_VIEW_SELECTED_ATTRIBUTES 403 -#define ID_VIEW_SORT_NAME 404 -#define ID_VIEW_SORT_TYPE 405 -#define ID_VIEW_SORT_SIZE 406 -#define ID_VIEW_SORT_DATE 407 -#define ID_VIEW_FILTER 409 -#define ID_VIEW_SPLIT 414 +#define ID_VIEW_SORT_NAME 404 +#define ID_VIEW_SORT_TYPE 405 +#define ID_VIEW_SORT_SIZE 406 +#define ID_VIEW_SORT_DATE 407 +#define ID_VIEW_FILTER 409 +#define ID_VIEW_SPLIT 414 #define ID_SELECT_FONT 510 #define ID_VIEW_TOOL_BAR 508 #define ID_VIEW_DRIVE_BAR 507 @@ -82,6 +83,20 @@ #define IDC_VIEW_TYPE_OTHERS 1004 #define IDC_VIEW_TYPE_HIDDEN 1005 +#define IDC_STATIC_PROP_FILENAME 1006 +#define IDC_STATIC_PROP_PATH 1007 +#define IDC_STATIC_PROP_LASTCHANGE 1008 +#define IDC_STATIC_PROP_VERSION 1009 +#define IDC_STATIC_PROP_COPYRIGHT 1010 +#define IDC_STATIC_PROP_SIZE 1011 +#define IDC_CHECK_READONLY 1012 +#define IDC_CHECK_ARCHIVE 1013 +#define IDC_CHECK_COMPRESSED 1014 +#define IDC_CHECK_HIDDEN 1015 +#define IDC_CHECK_SYSTEM 1016 +#define IDC_LIST_PROP_VERSION_TYPES 1017 +#define IDC_LIST_PROP_VERSION_VALUES 1018 + /* winefile extensions */ diff --git a/reactos/subsys/system/winefile/resource.rc b/reactos/subsys/system/winefile/resource.rc index c1d15b3826f..cf720a9cba1 100644 --- a/reactos/subsys/system/winefile/resource.rc +++ b/reactos/subsys/system/winefile/resource.rc @@ -24,6 +24,7 @@ IDA_WINEFILE ACCELERATORS DISCARDABLE VK_F8, ID_FILE_COPY, VIRTKEY, NOINVERT VK_DELETE, ID_FILE_DELETE, VIRTKEY, NOINVERT VK_RETURN, ID_ACTIVATE, VIRTKEY, NOINVERT + VK_RETURN, ID_EDIT_PROPERTIES, VIRTKEY, ALT, NOINVERT #ifndef _NO_EXTENSIONS "X", ID_FILE_EXIT, VIRTKEY, ALT, NOINVERT "S", ID_VIEW_FULLSCREEN, VIRTKEY, SHIFT, CONTROL, NOINVERT diff --git a/reactos/subsys/system/winefile/winefile.c b/reactos/subsys/system/winefile/winefile.c index b963f79bdca..9c2ad9758f9 100644 --- a/reactos/subsys/system/winefile/winefile.c +++ b/reactos/subsys/system/winefile/winefile.c @@ -204,6 +204,7 @@ static void set_curdir(ChildWnd* child, Entry* entry, int idx, HWND hwnd); static void refresh_child(ChildWnd* child); static void refresh_drives(); static void get_path(Entry* dir, PTSTR path); +static void format_date(const FILETIME* ft, TCHAR* buffer, int visible_cols); LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); @@ -1765,6 +1766,186 @@ static INT_PTR CALLBACK FilterDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, } +struct PropertiesDialog { + TCHAR path[MAX_PATH]; + Entry entry; + void* pVersionData; +}; + +/* Structure used to store enumerated languages and code pages. */ +struct LANGANDCODEPAGE { + WORD wLanguage; + WORD wCodePage; +} *lpTranslate; + +static LPCSTR InfoStrings[] = { + "Comments", + "CompanyName", + "FileDescription", + "FileVersion", + "InternalName", + "LegalCopyright", + "LegalTrademarks", + "OriginalFilename", + "PrivateBuild", + "ProductName", + "ProductVersion", + "SpecialBuild", + NULL +}; + +static void PropDlg_DisplayValue(HWND hlbox, HWND hedit) +{ + int idx = ListBox_GetCurSel(hlbox); + + if (idx != LB_ERR) { + LPCTSTR pValue = (LPCTSTR) ListBox_GetItemData(hlbox, idx); + + if (pValue) + SetWindowText(hedit, pValue); + } +} + +static void CheckForFileInfo(struct PropertiesDialog* dlg, HWND hwnd, LPCTSTR strFilename) +{ + static TCHAR sBackSlash[] = {'\\','\0'}; + static TCHAR sTranslation[] = {'\\','V','a','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n','\0'}; + static TCHAR sStringFileInfo[] = {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o','\\', + '%','0','4','x','%','0','4','x','\\','%','s','\0'}; + DWORD dwVersionDataLen = GetFileVersionInfoSize(strFilename, NULL); + + if (dwVersionDataLen) { + dlg->pVersionData = malloc(dwVersionDataLen); + + if (GetFileVersionInfo(strFilename, 0, dwVersionDataLen, dlg->pVersionData)) { + LPVOID pVal; + UINT nValLen; + + if (VerQueryValue(dlg->pVersionData, sBackSlash, &pVal, &nValLen)) { + if (nValLen == sizeof(VS_FIXEDFILEINFO)) { + VS_FIXEDFILEINFO* pFixedFileInfo = (VS_FIXEDFILEINFO*)pVal; + char buffer[BUFFER_LEN]; + + sprintf(buffer, "%d.%d.%d.%d", + HIWORD(pFixedFileInfo->dwFileVersionMS), LOWORD(pFixedFileInfo->dwFileVersionMS), + HIWORD(pFixedFileInfo->dwFileVersionLS), LOWORD(pFixedFileInfo->dwFileVersionLS)); + + SetDlgItemTextA(hwnd, IDC_STATIC_PROP_VERSION, buffer); + } + } + + /* Read the list of languages and code pages. */ + if (VerQueryValue(dlg->pVersionData, sTranslation, &pVal, &nValLen)) { + struct LANGANDCODEPAGE* pTranslate = (struct LANGANDCODEPAGE*)pVal; + struct LANGANDCODEPAGE* pEnd = (struct LANGANDCODEPAGE*)((LPBYTE)pVal+nValLen); + + HWND hlbox = GetDlgItem(hwnd, IDC_LIST_PROP_VERSION_TYPES); + + /* Read the file description for each language and code page. */ + for(; pTranslatewLanguage, pTranslate->wCodePage, pInfoString); + + /* Retrieve file description for language and code page */ + if (VerQueryValue(dlg->pVersionData, subblock, (PVOID)&pTxt, &nValLen)) { + int idx = ListBox_AddString(hlbox, pInfoString); + ListBox_SetItemData(hlbox, idx, pTxt); + } + } + } + + ListBox_SetCurSel(hlbox, 0); + + PropDlg_DisplayValue(hlbox, GetDlgItem(hwnd,IDC_LIST_PROP_VERSION_VALUES)); + } + } + } +} + +static INT_PTR CALLBACK PropertiesDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + static struct PropertiesDialog* dlg; + + switch(nmsg) { + case WM_INITDIALOG: { + const static TCHAR sByteFmt[] = {'%','s',' ','B','y','t','e','s','\0'}; + TCHAR b1[BUFFER_LEN], b2[BUFFER_LEN]; + NUMBERFMT fmt = {0}; + LPWIN32_FIND_DATA pWFD; + ULONGLONG size; + + dlg = (struct PropertiesDialog*) lparam; + pWFD = (LPWIN32_FIND_DATA) &dlg->entry.data; + + GetWindowText(hwnd, b1, MAX_PATH); + wsprintf(b2, b1, pWFD->cFileName); + SetWindowText(hwnd, b2); + + format_date(&pWFD->ftLastWriteTime, b1, COL_DATE|COL_TIME); + SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_LASTCHANGE), b1); + + size = ((ULONGLONG)pWFD->nFileSizeHigh << 32) | pWFD->nFileSizeLow; + wsprintf(b1, sLongNumFmt, size); + wsprintf(b2, sByteFmt, b1); + SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_SIZE), b2); + + SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_FILENAME), pWFD->cFileName); + SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_PATH), dlg->path); + + Button_SetCheck(GetDlgItem(hwnd,IDC_CHECK_READONLY), (pWFD->dwFileAttributes&FILE_ATTRIBUTE_READONLY? BST_CHECKED: BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(hwnd,IDC_CHECK_ARCHIVE), (pWFD->dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE? BST_CHECKED: BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(hwnd,IDC_CHECK_COMPRESSED), (pWFD->dwFileAttributes&FILE_ATTRIBUTE_COMPRESSED? BST_CHECKED: BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(hwnd,IDC_CHECK_HIDDEN), (pWFD->dwFileAttributes&FILE_ATTRIBUTE_HIDDEN? BST_CHECKED: BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(hwnd,IDC_CHECK_SYSTEM), (pWFD->dwFileAttributes&FILE_ATTRIBUTE_SYSTEM? BST_CHECKED: BST_UNCHECKED)); + + CheckForFileInfo(dlg, hwnd, dlg->path); + return 1;} + + case WM_COMMAND: { + int id = (int)wparam; + + switch(HIWORD(wparam)) { + case LBN_SELCHANGE: { + HWND hlbox = GetDlgItem(hwnd, IDC_LIST_PROP_VERSION_TYPES); + PropDlg_DisplayValue(hlbox, GetDlgItem(hwnd,IDC_LIST_PROP_VERSION_VALUES)); + break; + } + + case BN_CLICKED: + if (id==IDOK || id==IDCANCEL) + EndDialog(hwnd, id); + } + + return 1;} + + case WM_NCDESTROY: + free(dlg->pVersionData); + dlg->pVersionData = NULL; + break; + } + + return 0; +} + +static void show_properties_dlg(Entry* entry, HWND hwnd) +{ + struct PropertiesDialog dlg; + + memset(&dlg, 0, sizeof(struct PropertiesDialog)); + get_path(entry, dlg.path); + memcpy(&dlg.entry, entry, sizeof(Entry)); + + DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_DIALOG_PROPERTIES), hwnd, PropertiesDialogDlgProc, (LPARAM)&dlg); +} + + #ifndef _NO_EXTENSIONS static struct FullScreenParameters { @@ -3740,7 +3921,10 @@ static void activate_entry(ChildWnd* child, Pane* pane, HWND hwnd) #endif } } else { - launch_entry(entry, child->hwnd, SW_SHOWNORMAL); + if (GetKeyState(VK_MENU) < 0) + show_properties_dlg(entry, child->hwnd); + else + launch_entry(entry, child->hwnd, SW_SHOWNORMAL); } } @@ -4225,6 +4409,10 @@ LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam SetCapture(hwnd); break;} + case ID_EDIT_PROPERTIES: + show_properties_dlg(pane->cur, child->hwnd); + break; + default: return pane_command(pane, LOWORD(wparam)); } diff --git a/reactos/subsys/system/winefile/winefile.dsp b/reactos/subsys/system/winefile/winefile.dsp index daebb930b48..c582c724e9d 100644 --- a/reactos/subsys/system/winefile/winefile.dsp +++ b/reactos/subsys/system/winefile/winefile.dsp @@ -55,7 +55,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib mpr.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib version.lib mpr.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "winefile - Win32 Unicode Debug" @@ -81,7 +81,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib mpr.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib version.lib mpr.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "winefile - Win32 UNICODE Release" @@ -108,7 +108,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib mpr.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib version.lib mpr.lib /nologo /subsystem:windows /machine:I386 !ELSEIF "$(CFG)" == "winefile - Win32 Release" @@ -135,7 +135,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib mpr.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 user32.lib gdi32.lib advapi32.lib comctl32.lib shell32.lib comdlg32.lib ole32.lib version.lib mpr.lib /nologo /subsystem:windows /machine:I386 !ENDIF diff --git a/reactos/subsys/system/winefile/winefile.xml b/reactos/subsys/system/winefile/winefile.xml index 7a987c89bf7..0a5027f5afb 100644 --- a/reactos/subsys/system/winefile/winefile.xml +++ b/reactos/subsys/system/winefile/winefile.xml @@ -15,6 +15,7 @@ shell32 ole32 oleaut32 + version mpr license.c winefile.c