1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// OverwriteDialog.cpp
#include "StdAfx.h"
#include "OverwriteDialog.h"
#include "Common/StringConvert.h"
#include "Windows/FileName.h"
#include "Windows/Defs.h"
#include "Windows/ResourceString.h"
#include "Windows/Control/Static.h"
#include "Windows/PropVariantConversions.h"
#include "../../FormatUtils.h"
// #include "../resource.h"
#ifdef LANG
#include "../../LangUtils.h"
#endif
using namespace NWindows;
#ifdef LANG
static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
{ IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
{ IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 },
{ IDYES, 0x02000705 },
{ IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 },
{ IDNO, 0x02000709 },
{ IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B },
{ IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 },
{ IDCANCEL, 0x02000711 }
};
#endif
void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
const NOverwriteDialog::CFileInfo &fileInfo)
{
UString sizeString;
if (fileInfo.SizeIsDefined)
sizeString = MyFormatNew(IDS_FILE_SIZE,
#ifdef LANG
0x02000982,
#endif
NumberToString(fileInfo.Size));
UString reducedName;
const int kLineSize = 88;
for (int i = 0; i < fileInfo.Name.Length();)
{
reducedName += fileInfo.Name.Mid(i, kLineSize);
reducedName += L" ";
i += kLineSize;
}
UString fullString = reducedName;
fullString += L"\n";
fullString += sizeString;
fullString += L"\n";
if (fileInfo.TimeIsDefined)
{
UString timeString;
FILETIME localFileTime;
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
throw 4190402;
timeString = ConvertFileTimeToString(localFileTime);
fullString +=
#ifdef LANG
LangString(IDS_FILE_MODIFIED, 0x02000983);
#else
MyLoadStringW(IDS_FILE_MODIFIED);
#endif
fullString += L" ";
fullString += timeString;
}
NWindows::NControl::CDialogChildControl control;
control.Init(*this, textID);
control.SetText(fullString);
SHFILEINFO shellFileInfo;
if (::SHGetFileInfo(
GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
{
NControl::CStatic staticContol;
staticContol.Attach(GetItem(iconID));
staticContol.SetIcon(shellFileInfo.hIcon);
}
}
bool COverwriteDialog::OnInit()
{
#ifdef LANG
LangSetWindowText(HWND(*this), 0x02000900);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME,
IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo);
return CModalDialog::OnInit();
}
bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
switch(buttonID)
{
case IDYES:
case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
case IDNO:
case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
End(buttonID);
return true;
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
|