mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
Simplify NativeLangSpeaker::messageBox.
This commit is contained in:
parent
d0bafb7fba
commit
ad2cc85c0e
@ -1074,38 +1074,17 @@ generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const
|
|||||||
int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *defaultMessage, const TCHAR *defaultTitle, int msgBoxType, int intInfo, const TCHAR *strInfo)
|
int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *defaultMessage, const TCHAR *defaultTitle, int msgBoxType, int intInfo, const TCHAR *strInfo)
|
||||||
{
|
{
|
||||||
generic_string msg, title;
|
generic_string msg, title;
|
||||||
size_t index;
|
|
||||||
TCHAR int2Write[256];
|
|
||||||
TCHAR intPlaceHolderSymbol[] = TEXT("$INT_REPLACE$");
|
|
||||||
TCHAR strPlaceHolderSymbol[] = TEXT("$STR_REPLACE$");
|
|
||||||
|
|
||||||
size_t intPlaceHolderLen = lstrlen(intPlaceHolderSymbol);
|
|
||||||
size_t strPlaceHolderLen = lstrlen(strPlaceHolderSymbol);
|
|
||||||
|
|
||||||
generic_sprintf(int2Write, TEXT("%d"), intInfo);
|
|
||||||
|
|
||||||
if (!getMsgBoxLang(msgBoxTagName, title, msg))
|
if (!getMsgBoxLang(msgBoxTagName, title, msg))
|
||||||
{
|
{
|
||||||
title = defaultTitle;
|
title = defaultTitle;
|
||||||
msg = defaultMessage;
|
msg = defaultMessage;
|
||||||
}
|
}
|
||||||
index = title.find(intPlaceHolderSymbol);
|
title = stringReplace(title, TEXT("$INT_REPLACE$"), std::to_wstring(intInfo));
|
||||||
if (index != string::npos)
|
msg = stringReplace(msg, TEXT("$INT_REPLACE$"), std::to_wstring(intInfo));
|
||||||
title.replace(index, intPlaceHolderLen, int2Write);
|
|
||||||
|
|
||||||
index = msg.find(intPlaceHolderSymbol);
|
|
||||||
if (index != string::npos)
|
|
||||||
msg.replace(index, intPlaceHolderLen, int2Write);
|
|
||||||
|
|
||||||
if (strInfo)
|
if (strInfo)
|
||||||
{
|
{
|
||||||
index = title.find(strPlaceHolderSymbol);
|
title = stringReplace(title, TEXT("$STR_REPLACE$"), strInfo);
|
||||||
if (index != string::npos)
|
msg = stringReplace(msg, TEXT("$STR_REPLACE$"), strInfo);
|
||||||
title.replace(index, strPlaceHolderLen, strInfo);
|
|
||||||
|
|
||||||
index = msg.find(strPlaceHolderSymbol);
|
|
||||||
if (index != string::npos)
|
|
||||||
msg.replace(index, strPlaceHolderLen, strInfo);
|
|
||||||
}
|
}
|
||||||
return ::MessageBox(hWnd, msg.c_str(), title.c_str(), msgBoxType);
|
return ::MessageBox(hWnd, msg.c_str(), title.c_str(), msgBoxType);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user