mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-21 12:54:42 +02:00
[BUG_FIXED] Fix file ext unexpected behaviour.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@546 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
d36fd964e4
commit
2478059b5d
@ -261,6 +261,7 @@ static HWND hFileDlg = NULL;
|
|||||||
static WNDPROC oldProc = NULL;
|
static WNDPROC oldProc = NULL;
|
||||||
static generic_string currentExt = TEXT("");
|
static generic_string currentExt = TEXT("");
|
||||||
|
|
||||||
|
|
||||||
static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@ -278,7 +279,7 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
if (currentExt != TEXT(""))
|
if (currentExt != TEXT(""))
|
||||||
{
|
{
|
||||||
generic_string fnExt = changeExt(fn, currentExt);
|
generic_string fnExt = changeExt(fn, currentExt, false);
|
||||||
::SetWindowText(fnControl, fnExt.c_str());
|
::SetWindowText(fnControl, fnExt.c_str());
|
||||||
}
|
}
|
||||||
return oldProc(hwnd, message, wParam, lParam);
|
return oldProc(hwnd, message, wParam, lParam);
|
||||||
@ -292,6 +293,7 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
return oldProc(hwnd, message, wParam, lParam);
|
return oldProc(hwnd, message, wParam, lParam);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt)
|
static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt)
|
||||||
TCHAR *begin = ext;
|
TCHAR *begin = ext;
|
||||||
for ( ; *begin != '.' ; begin++);
|
for ( ; *begin != '.' ; begin++);
|
||||||
@ -441,7 +443,7 @@ void goToCenter(HWND hwnd)
|
|||||||
::SetWindowPos(hwnd, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
|
::SetWindowPos(hwnd, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_string changeExt(generic_string fn, generic_string ext)
|
generic_string changeExt(generic_string fn, generic_string ext, bool forceReplaced)
|
||||||
{
|
{
|
||||||
if (ext == TEXT(""))
|
if (ext == TEXT(""))
|
||||||
return fn;
|
return fn;
|
||||||
@ -455,7 +457,7 @@ generic_string changeExt(generic_string fn, generic_string ext)
|
|||||||
{
|
{
|
||||||
fnExt += extension;
|
fnExt += extension;
|
||||||
}
|
}
|
||||||
else
|
else if (forceReplaced)
|
||||||
{
|
{
|
||||||
int len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1;
|
int len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1;
|
||||||
fnExt.replace(index, len, extension);
|
fnExt.replace(index, len, extension);
|
||||||
|
@ -52,7 +52,7 @@ struct OPENFILENAMENPP {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
generic_string changeExt(generic_string fn, generic_string ext);
|
generic_string changeExt(generic_string fn, generic_string ext, bool forceReplaced = true);
|
||||||
void goToCenter(HWND hwnd);
|
void goToCenter(HWND hwnd);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user