implemented file properties dialog (partly based on Rob D.'s winfile code)

svn path=/trunk/; revision=15739
This commit is contained in:
Martin Fuchs 2005-06-02 21:39:00 +00:00
parent dcf3800a39
commit 9719715092
6 changed files with 251 additions and 16 deletions

View file

@ -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
{

View file

@ -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 */
@ -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 */

View file

@ -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

View file

@ -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(; pTranslate<pEnd; ++pTranslate) {
LPCSTR* p;
for(p=InfoStrings; *p; ++p) {
TCHAR subblock[200];
LPCTSTR pTxt;
UINT nValLen;
LPCSTR pInfoString = *p;
wsprintf(subblock, sStringFileInfo, pTranslate->wLanguage, 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,6 +3921,9 @@ static void activate_entry(ChildWnd* child, Pane* pane, HWND hwnd)
#endif
}
} else {
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));
}

View file

@ -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

View file

@ -15,6 +15,7 @@
<library>shell32</library>
<library>ole32</library>
<library>oleaut32</library>
<library>version</library>
<library>mpr</library>
<file>license.c</file>
<file>winefile.c</file>