summaryrefslogtreecommitdiff
path: root/src/core/stdfile/fileexistsdlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/stdfile/fileexistsdlg.cpp')
-rw-r--r--src/core/stdfile/fileexistsdlg.cpp280
1 files changed, 143 insertions, 137 deletions
diff --git a/src/core/stdfile/fileexistsdlg.cpp b/src/core/stdfile/fileexistsdlg.cpp
index 72930fe482..1e604c2947 100644
--- a/src/core/stdfile/fileexistsdlg.cpp
+++ b/src/core/stdfile/fileexistsdlg.cpp
@@ -60,10 +60,10 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd,
IShellFolder *pFileFolder;
for (pidl = pCurrentIdl;;) {
- pidlNext = (ITEMIDLIST*)((PBYTE)pidl+pidl->mkid.cb);
+ pidlNext = (ITEMIDLIST*)((PBYTE)pidl + pidl->mkid.cb);
if (pidlNext->mkid.cb == 0) {
- pidlFilename = (ITEMIDLIST*)CoTaskMemAlloc(pidl->mkid.cb+sizeof(pidl->mkid.cb));
- CopyMemory(pidlFilename, pidl, pidl->mkid.cb+sizeof(pidl->mkid.cb));
+ pidlFilename = (ITEMIDLIST*)CoTaskMemAlloc(pidl->mkid.cb + sizeof(pidl->mkid.cb));
+ CopyMemory(pidlFilename, pidl, pidl->mkid.cb + sizeof(pidl->mkid.cb));
pidl->mkid.cb = 0;
break;
}
@@ -72,33 +72,33 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd,
if (pDesktopFolder->BindToObject(pCurrentIdl, NULL, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) {
IContextMenu *pContextMenu;
if (pFileFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, NULL, (void**)&pContextMenu) == NOERROR) {
- switch(cmd) {
- case C_PROPERTIES:
- { CMINVOKECOMMANDINFO ici = {0};
+ switch (cmd) {
+ case C_PROPERTIES:
+ {
+ CMINVOKECOMMANDINFO ici = { 0 };
ici.cbSize = sizeof(ici);
ici.hwnd = hwnd;
ici.lpVerb = "properties";
ici.nShow = SW_SHOW;
pContextMenu->InvokeCommand(&ici);
- break;
}
- case C_CONTEXTMENU:
- {
- HMENU hMenu = CreatePopupMenu();
- if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) {
- int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL);
- if (cmd) {
- CMINVOKECOMMANDINFO ici = {0};
- ici.cbSize = sizeof(ici);
- ici.hwnd = hwnd;
- ici.lpVerb = MAKEINTRESOURCEA(cmd-1000);
- ici.nShow = SW_SHOW;
- pContextMenu->InvokeCommand(&ici);
- }
+ break;
+
+ case C_CONTEXTMENU:
+ HMENU hMenu = CreatePopupMenu();
+ if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT) & 0x8000 ? CMF_EXTENDEDVERBS : 0) | CMF_NORMAL))) {
+ int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL);
+ if (cmd) {
+ CMINVOKECOMMANDINFO ici = { 0 };
+ ici.cbSize = sizeof(ici);
+ ici.hwnd = hwnd;
+ ici.lpVerb = MAKEINTRESOURCEA(cmd - 1000);
+ ici.nShow = SW_SHOW;
+ pContextMenu->InvokeCommand(&ici);
}
- DestroyMenu(hMenu);
- break;
}
+ DestroyMenu(hMenu);
+ break;
}
pContextMenu->Release();
}
@@ -116,7 +116,7 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
{
PROTOFILETRANSFERSTATUS* pft = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_LBUTTONDBLCLK:
ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW);
break;
@@ -140,7 +140,7 @@ void __cdecl LoadIconsAndTypesThread(void* param)
loadiconsstartinfo *info = (loadiconsstartinfo*)param;
SHFILEINFO fileInfo;
- if (SHGetFileInfo(info->szFilename, 0, &fileInfo, sizeof(fileInfo), SHGFI_TYPENAME|SHGFI_ICON|SHGFI_LARGEICON)) {
+ if (SHGetFileInfo(info->szFilename, 0, &fileInfo, sizeof(fileInfo), SHGFI_TYPENAME | SHGFI_ICON | SHGFI_LARGEICON)) {
TCHAR szExtension[64], szIconFile[MAX_PATH];
TCHAR *pszFilename = _tcsrchr(info->szFilename, '\\');
@@ -149,7 +149,7 @@ void __cdecl LoadIconsAndTypesThread(void* param)
TCHAR *pszExtension = _tcsrchr(pszFilename, '.');
if (pszExtension)
- lstrcpyn(szExtension, pszExtension+1, SIZEOF(szExtension));
+ lstrcpyn(szExtension, pszExtension + 1, SIZEOF(szExtension));
else {
pszExtension = _T(".");
szExtension[0] = '\0';
@@ -161,7 +161,7 @@ void __cdecl LoadIconsAndTypesThread(void* param)
SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName);
SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0);
szIconFile[0] = '\0';
- if ( !lstrcmp(szExtension, _T("EXE")))
+ if (!lstrcmp(szExtension, _T("EXE")))
SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile));
else {
TCHAR szTypeName[MAX_PATH];
@@ -171,11 +171,13 @@ void __cdecl LoadIconsAndTypesThread(void* param)
if (_tcsstr(szIconFile, _T("%1")))
SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, SIZEOF(szIconFile));
else szIconFile[0] = '\0';
- } } }
+ }
+ }
+ }
if (szIconFile[0]) {
TCHAR *pszComma = _tcsrchr(szIconFile, ',');
- int iconIndex = (pszComma == NULL) ? 0 :_ttoi(pszComma+1); *pszComma = '\0';
+ int iconIndex = (pszComma == NULL) ? 0 : _ttoi(pszComma + 1); *pszComma = '\0';
HICON hIcon = ExtractIcon(hInst, szIconFile, iconIndex);
if (hIcon)
fileInfo.hIcon = hIcon;
@@ -189,128 +191,132 @@ void __cdecl LoadIconsAndTypesThread(void* param)
INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
PROTOFILETRANSFERSTATUS *fts = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TCHAR szSize[64];
- struct _stati64 statbuf;
- struct TDlgProcFileExistsParam *dat = (struct TDlgProcFileExistsParam *)lParam;
-
- SetPropA(hwndDlg, "Miranda.Preshutdown", HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN));
- SetPropA(hwndDlg, "Miranda.ParentWnd", dat->hwndParent);
-
TranslateDialogDefault(hwndDlg);
- fts = (PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS));
- CopyProtoFileTransferStatus(fts, dat->fts);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts);
- SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile);
- SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime);
- GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL);
- SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize);
-
- mir_subclassWindow( GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc);
-
- HWND hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME);
- if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) {
- SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime);
- GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL);
- SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize);
- if (statbuf.st_size>(int)fts->currentFileSize) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE);
- hwndFocus = GetDlgItem(hwndDlg, IDC_OVERWRITE);
- } }
-
- loadiconsstartinfo *lisi = (loadiconsstartinfo*)mir_alloc(sizeof(loadiconsstartinfo));
- lisi->hwndDlg = hwndDlg;
- lisi->szFilename = mir_tstrdup(fts->tszCurrentFile);
- //can be a little slow, so why not?
- forkthread(LoadIconsAndTypesThread, 0, lisi);
- SetFocus(hwndFocus);
- SetWindowLongPtr(hwndFocus, GWL_STYLE, GetWindowLongPtr(hwndFocus, GWL_STYLE)|BS_DEFPUSHBUTTON);
- return FALSE;
- }
- case WM_COMMAND:
- {
- PROTOFILERESUME pfr = {0};
- switch(LOWORD(wParam)) {
- case IDC_OPENFILE:
- ShellExecute(hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW);
- return FALSE;
-
- case IDC_OPENFOLDER:
{
- TCHAR szFile[MAX_PATH];
- lstrcpyn(szFile, fts->tszCurrentFile, SIZEOF(szFile));
- TCHAR *pszLastBackslash = _tcsrchr(szFile, '\\');
- if (pszLastBackslash)
- *pszLastBackslash = '\0';
- ShellExecute(hwndDlg, NULL, szFile, NULL, NULL, SW_SHOW);
- return FALSE;
+ TCHAR szSize[64];
+ struct _stati64 statbuf;
+ struct TDlgProcFileExistsParam *dat = (struct TDlgProcFileExistsParam *)lParam;
+
+ SetPropA(hwndDlg, "Miranda.Preshutdown", HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN));
+ SetPropA(hwndDlg, "Miranda.ParentWnd", dat->hwndParent);
+
+ fts = (PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS));
+ CopyProtoFileTransferStatus(fts, dat->fts);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts);
+ SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile);
+ SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime);
+ GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL);
+ SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize);
+
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc);
+
+ HWND hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME);
+ if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) {
+ SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime);
+ GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL);
+ SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize);
+ if (statbuf.st_size > (int)fts->currentFileSize) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE);
+ hwndFocus = GetDlgItem(hwndDlg, IDC_OVERWRITE);
+ }
+ }
+
+ loadiconsstartinfo *lisi = (loadiconsstartinfo*)mir_alloc(sizeof(loadiconsstartinfo));
+ lisi->hwndDlg = hwndDlg;
+ lisi->szFilename = mir_tstrdup(fts->tszCurrentFile);
+ //can be a little slow, so why not?
+ forkthread(LoadIconsAndTypesThread, 0, lisi);
+ SetFocus(hwndFocus);
+ SetWindowLongPtr(hwndFocus, GWL_STYLE, GetWindowLongPtr(hwndFocus, GWL_STYLE) | BS_DEFPUSHBUTTON);
}
- case IDC_PROPERTIES:
- DoAnnoyingShellCommand(hwndDlg, fts->tszCurrentFile, C_PROPERTIES, NULL);
- return FALSE;
- case IDC_RESUME:
- pfr.action = FILERESUME_RESUME;
- break;
- case IDC_RESUMEALL:
- pfr.action = FILERESUME_RESUMEALL;
- break;
- case IDC_OVERWRITE:
- pfr.action = FILERESUME_OVERWRITE;
- break;
- case IDC_OVERWRITEALL:
- pfr.action = FILERESUME_OVERWRITEALL;
- break;
-
- case IDC_AUTORENAME:
- pfr.action = FILERESUME_RENAMEALL;
- break;
-
- case IDC_SAVEAS:
+ return FALSE;
+
+ case WM_COMMAND:
{
- OPENFILENAME ofn = {0};
- TCHAR filter[512], *pfilter;
- TCHAR str[MAX_PATH];
-
- lstrcpyn(str, fts->tszCurrentFile, SIZEOF(str));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- _tcscpy(filter, TranslateT("All files"));
- _tcscat(filter, _T(" (*)"));
- pfilter = filter + _tcslen(filter) + 1;
- _tcscpy(pfilter, _T("*"));
- pfilter = pfilter + _tcslen(pfilter) + 1;
- *pfilter = '\0';
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = str;
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- if ( !GetSaveFileName(&ofn))
+ PROTOFILERESUME pfr = { 0 };
+ switch (LOWORD(wParam)) {
+ case IDC_OPENFILE:
+ ShellExecute(hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW);
return FALSE;
- pfr.szFilename = mir_tstrdup(str);
- pfr.action = FILERESUME_RENAME;
- break;
- }
- case IDC_SKIP:
- pfr.action = FILERESUME_SKIP;
- break;
- case IDCANCEL:
- pfr.action = FILERESUME_CANCEL;
- break;
- default:
- return FALSE;
- }
- {
+ case IDC_OPENFOLDER:
+ {
+ TCHAR szFile[MAX_PATH];
+ lstrcpyn(szFile, fts->tszCurrentFile, SIZEOF(szFile));
+ TCHAR *pszLastBackslash = _tcsrchr(szFile, '\\');
+ if (pszLastBackslash)
+ *pszLastBackslash = '\0';
+ ShellExecute(hwndDlg, NULL, szFile, NULL, NULL, SW_SHOW);
+ }
+ return FALSE;
+ case IDC_PROPERTIES:
+ DoAnnoyingShellCommand(hwndDlg, fts->tszCurrentFile, C_PROPERTIES, NULL);
+ return FALSE;
+ case IDC_RESUME:
+ pfr.action = FILERESUME_RESUME;
+ break;
+ case IDC_RESUMEALL:
+ pfr.action = FILERESUME_RESUMEALL;
+ break;
+ case IDC_OVERWRITE:
+ pfr.action = FILERESUME_OVERWRITE;
+ break;
+ case IDC_OVERWRITEALL:
+ pfr.action = FILERESUME_OVERWRITEALL;
+ break;
+
+ case IDC_AUTORENAME:
+ pfr.action = FILERESUME_RENAMEALL;
+ break;
+
+ case IDC_SAVEAS:
+ {
+ OPENFILENAME ofn = { 0 };
+ TCHAR filter[512], *pfilter;
+ TCHAR str[MAX_PATH];
+
+ lstrcpyn(str, fts->tszCurrentFile, SIZEOF(str));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+ _tcscpy(filter, TranslateT("All files"));
+ _tcscat(filter, _T(" (*)"));
+ pfilter = filter + _tcslen(filter) + 1;
+ _tcscpy(pfilter, _T("*"));
+ pfilter = pfilter + _tcslen(pfilter) + 1;
+ *pfilter = '\0';
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ if (!GetSaveFileName(&ofn))
+ return FALSE;
+
+ pfr.szFilename = mir_tstrdup(str);
+ pfr.action = FILERESUME_RENAME;
+ }
+ break;
+
+ case IDC_SKIP:
+ pfr.action = FILERESUME_SKIP;
+ break;
+
+ case IDCANCEL:
+ pfr.action = FILERESUME_CANCEL;
+ break;
+
+ default:
+ return FALSE;
+ }
+
PROTOFILERESUME *pfrCopy = (PROTOFILERESUME*)mir_alloc(sizeof(pfr));
CopyMemory(pfrCopy, &pfr, sizeof(pfr));
PostMessage((HWND)GetPropA(hwndDlg, "Miranda.ParentWnd"), M_FILEEXISTSDLGREPLY, (WPARAM)mir_tstrdup(fts->tszCurrentFile), (LPARAM)pfrCopy);
DestroyWindow(hwndDlg);
}
break;
- }
case WM_CLOSE:
PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDCANCEL));