parent
496e93e1b0
commit
c4f493a7c8
@ -474,15 +474,19 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
// change to backslash, and insert trailing '\' to indicate directory
|
// change to backslash, and insert trailing '\' to indicate directory
|
||||||
hFileDlg = ::GetParent(hWnd);
|
hFileDlg = ::GetParent(hWnd);
|
||||||
std::wstring _fnStr(fileName);
|
std::wstring filePath(fileName);
|
||||||
std::replace(_fnStr.begin(), _fnStr.end(), '/', '\\');
|
std::replace(filePath.begin(), filePath.end(), '/', '\\');
|
||||||
|
|
||||||
if (_fnStr.back() != '\\')
|
if (filePath.back() != '\\')
|
||||||
_fnStr.insert(_fnStr.end(), '\\');
|
filePath.insert(filePath.end(), '\\');
|
||||||
|
|
||||||
|
// There are two or more double backslash, then change it to single
|
||||||
|
while (filePath.find(L"\\\\") != std::wstring::npos)
|
||||||
|
filePath.replace(filePath.find(TEXT("\\\\")), 2, TEXT("\\"));
|
||||||
|
|
||||||
// change the dialog directory selection
|
// change the dialog directory selection
|
||||||
::SendMessage(hFileDlg, CDM_SETCONTROLTEXT, edt1,
|
::SendMessage(hFileDlg, CDM_SETCONTROLTEXT, edt1,
|
||||||
reinterpret_cast<LPARAM>(_fnStr.c_str()));
|
reinterpret_cast<LPARAM>(filePath.c_str()));
|
||||||
::PostMessage(hFileDlg, WM_COMMAND, IDOK, 0);
|
::PostMessage(hFileDlg, WM_COMMAND, IDOK, 0);
|
||||||
::SetWindowLongPtr(hWnd, 0 /*DWL_MSGRESULT*/, 1);
|
::SetWindowLongPtr(hWnd, 0 /*DWL_MSGRESULT*/, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user