Implement file properties dialog (partly based on Rob D.'s winfile

code).
This commit is contained in:
Martin Fuchs 2005-06-06 10:02:43 +00:00 committed by Alexandre Julliard
parent 520a7af933
commit 3512161ddb
6 changed files with 273 additions and 2 deletions

View File

@ -200,6 +200,36 @@ BEGIN
PUSHBUTTON "Abbrechen",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 "Abbrechen",IDCANCEL,191,29,50,14
LTEXT "&Dateiname:",-1,7,7,59,9
EDITTEXT IDC_STATIC_PROP_FILENAME,71,7,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP
LTEXT "&Pfad:",-1,7,18,59,9
EDITTEXT IDC_STATIC_PROP_PATH,71,18,120,9, ES_READONLY | NOT WS_BORDER | WS_TABSTOP
LTEXT "Letzte &Änderung:",-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 "&Copyright:",-1,7,51,59,9
EDITTEXT IDC_STATIC_PROP_COPYRIGHT,71,51,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP
LTEXT "&Größe:",-1,7,62,59,9
EDITTEXT IDC_STATIC_PROP_SIZE,71,62,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP
GROUPBOX "Attribute",-1,7,79,158,46
CONTROL "&Schreibgeschützt",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,91,68,9
CONTROL "&Versteckt",IDC_CHECK_HIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,91,68,9
CONTROL "&Archiv",IDC_CHECK_ARCHIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,68,9
CONTROL "Sys&tem",IDC_CHECK_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,101,68,9
CONTROL "&Komprimiert",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9
GROUPBOX "&Versionsinformationen",-1,7,129,234,79
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

@ -200,6 +200,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
CONTROL "&Read Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,91,68,9
CONTROL "H&idden",IDC_CHECK_HIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,91,68,9
CONTROL "&Archive",IDC_CHECK_ARCHIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,68,9
CONTROL "&System",IDC_CHECK_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,101,68,9
CONTROL "&Compressed",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9
GROUPBOX "&Version Information",-1,7,129,234,79
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

@ -5,7 +5,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winefile.exe
APPMODE = -mwindows
IMPORTS = shell32 comdlg32 comctl32 ole32 mpr user32 gdi32 advapi32 kernel32
IMPORTS = shell32 comdlg32 comctl32 ole32 mpr version user32 gdi32 advapi32 kernel32
EXTRALIBS = -luuid
C_SRCS = \

View File

@ -34,6 +34,7 @@
#define IDD_EXECUTE 103
#define IDD_SELECT_DESTINATION 104
#define IDD_DIALOG_VIEW_TYPE 105
#define IDD_DIALOG_PROPERTIES 106
/* control ids */
@ -80,6 +81,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 */
#define ID_ABOUT_WINE 0x8000

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

@ -171,6 +171,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);
@ -1717,6 +1718,193 @@ 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];
#ifdef UNICODE
TCHAR infoStr[100];
#endif
LPCTSTR pTxt;
UINT nValLen;
LPCSTR pInfoString = *p;
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, pInfoString, -1, infoStr, 100);
#else
#define infoStr pInfoString
#endif
wsprintf(subblock, sStringFileInfo, pTranslate->wLanguage, pTranslate->wCodePage, infoStr);
/* Retrieve file description for language and code page */
if (VerQueryValue(dlg->pVersionData, subblock, (PVOID)&pTxt, &nValLen)) {
int idx = ListBox_AddString(hlbox, infoStr);
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];
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 {
@ -3673,6 +3861,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);
}
}
@ -4148,6 +4339,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));
}