[ENHANCEMENT] Enhance warning message when the amount of files to open is too important.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@909 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2012-05-12 09:31:00 +00:00
parent 5d28d74ac7
commit 43f4e4c45a
5 changed files with 55 additions and 7 deletions

View File

@ -610,6 +610,9 @@
<FileLockedWarning title="Save failed" message="Please check whether if this file is opened in another program"/> <FileLockedWarning title="Save failed" message="Please check whether if this file is opened in another program"/>
<FileAlreadyOpenedInNpp title="" message="The file is already opened in the Notepad++."/> <FileAlreadyOpenedInNpp title="" message="The file is already opened in the Notepad++."/>
<DeleteFileFailed title="Delete File" message="Delete File failed"/> <DeleteFileFailed title="Delete File" message="Delete File failed"/>
<!-- $INT_REPLACE$ is a place holder, don't translate it -->
<NbFileToOpenImportantWaring title="Amount of files to open is too large" message="$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"/>
</MessageBox> </MessageBox>
<ProjectManager> <ProjectManager>
<PanelTitle name="Project"/> <PanelTitle name="Project"/>

View File

@ -197,9 +197,10 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
{ {
int answer = _nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring", int answer = _nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring",
_pPublicInterface->getHSelf(), _pPublicInterface->getHSelf(),
TEXT("Number of files to open are too important.\rAre you sure to open them?"), TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"),
TEXT("Amount of files to open is too large"), TEXT("Amount of files to open is too large"),
MB_YESNO|MB_APPLMODAL); MB_YESNO|MB_APPLMODAL,
nbFiles2Open);
ok2Open = answer == IDYES; ok2Open = answer == IDYES;
} }

View File

@ -739,6 +739,13 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea
if(bufferSizeRequested > INT_MAX) if(bufferSizeRequested > INT_MAX)
{ {
::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL); ::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL);
/*
_nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring",
_pPublicInterface->getHSelf(),
TEXT("File is too big to be opened by Notepad++"),
TEXT("File open problem"),
MB_OK|MB_APPLMODAL);
*/
fclose(fp); fclose(fp);
return false; return false;
} }

View File

@ -1321,12 +1321,49 @@ generic_string NativeLangSpeaker::getProjectPanelLangStr(const char *nodeName, c
return defaultStr; return defaultStr;
} }
int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *defaultMessage, TCHAR *defaultTitle, int msgBoxType) int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *defaultMessage, TCHAR *defaultTitle, int msgBoxType, int intInfo, TCHAR *strInfo)
{ {
generic_string msg, title; generic_string msg, title;
if (getMsgBoxLang(msgBoxTagName, title, msg)) 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))
{ {
title = defaultTitle;
msg = defaultMessage;
}
index = title.find(intPlaceHolderSymbol);
if (index != string::npos)
title.replace(index, intPlaceHolderLen, int2Write);
index = msg.find(intPlaceHolderSymbol);
if (index != string::npos)
msg.replace(index, intPlaceHolderLen, int2Write);
if (strInfo)
{
index = title.find(strPlaceHolderSymbol);
if (index != string::npos)
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);
}
/*
defaultTitle.replace(index, len, int2Write);
defaultTitle.replace(index, len, str2Write);
defaultMessage.replace(index, len, int2Write);
defaultMessage.replace(index, len, str2Write);
return ::MessageBox(hWnd, defaultMessage, defaultTitle, msgBoxType); return ::MessageBox(hWnd, defaultMessage, defaultTitle, msgBoxType);
*/
} }

View File

@ -74,7 +74,7 @@ public:
bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message); bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message);
generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const; generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const;
generic_string getProjectPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const; generic_string getProjectPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const;
int messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *message, TCHAR *title, int msgBoxType); int messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *message, TCHAR *title, int msgBoxType, int intInfo = 0, TCHAR *strInfo = NULL);
private: private:
TiXmlNodeA *_nativeLangA; TiXmlNodeA *_nativeLangA;
int _nativeLangEncoding; int _nativeLangEncoding;