diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-20 12:18:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-20 12:18:34 +0000 |
commit | 270a21131e48439a96265a38a32e793a9d5f1938 (patch) | |
tree | 106d3923571da8df441b062334c1dc66c7eabcaf /plugins/TabSRMM/src/utils.cpp | |
parent | 14fa6ff7baf4b7691eca6a41e756c5d3375ad000 (diff) |
minus some horrors in tabs
git-svn-id: http://svn.miranda-ng.org/main/trunk@5760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/utils.cpp')
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index d278132555..ea00b2c729 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -1022,34 +1022,31 @@ DWORD CALLBACK Utils::StreamOut(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * extract a resource from the given module
* tszPath must end with \
*/
-void TSAPI Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszName, const TCHAR *tszPath,
+bool TSAPI Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszName, const TCHAR *tszPath,
const TCHAR *tszFilename, bool fForceOverwrite)
{
- HRSRC hRes;
- HGLOBAL hResource;
- TCHAR szFilename[MAX_PATH];
-
- hRes = FindResource(h, MAKEINTRESOURCE(uID), tszName);
-
+ HRSRC hRes = FindResource(h, MAKEINTRESOURCE(uID), tszName);
if (hRes) {
- hResource = LoadResource(h, hRes);
+ HGLOBAL hResource = LoadResource(h, hRes);
if (hResource) {
- HANDLE hFile;
char *pData = (char *)LockResource(hResource);
DWORD dwSize = SizeofResource(g_hInst, hRes), written = 0;
+
+ TCHAR szFilename[MAX_PATH];
mir_sntprintf(szFilename, MAX_PATH, _T("%s%s"), tszPath, tszFilename);
- if (!fForceOverwrite) {
+ if (!fForceOverwrite)
if (PathFileExists(szFilename))
- return;
- }
- if ((hFile = CreateFile(szFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) {
- WriteFile(hFile, (void*)pData, dwSize, &written, NULL);
- CloseHandle(hFile);
- }
- else
- throw(CRTException("Error while extracting aero skin images, Aero mode disabled.", szFilename));
+ return true;
+
+ HANDLE hFile = CreateFile(szFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+ if (hFile == INVALID_HANDLE_VALUE)
+ return false;
+
+ WriteFile(hFile, (void*)pData, dwSize, &written, NULL);
+ CloseHandle(hFile);
}
}
+ return true;
}
/**
@@ -1141,24 +1138,19 @@ HMODULE Utils::loadSystemLibrary(const wchar_t* szFilename) wchar_t sysPathName[MAX_PATH + 2];
HMODULE _h = 0;
- try {
- if (0 == ::GetSystemDirectoryW(sysPathName, MAX_PATH))
- throw(CRTException("Error while loading system library", szFilename));
+ if (0 == ::GetSystemDirectoryW(sysPathName, MAX_PATH))
+ return 0;
- sysPathName[MAX_PATH - 1] = 0;
- if (wcslen(sysPathName) + wcslen(szFilename) >= MAX_PATH)
- throw(CRTException("Error while loading system library", szFilename));
+ sysPathName[MAX_PATH - 1] = 0;
+ if (wcslen(sysPathName) + wcslen(szFilename) >= MAX_PATH)
+ return 0;
- lstrcatW(sysPathName, szFilename);
- _h = LoadLibraryW(sysPathName);
- if (0 == _h)
- throw(CRTException("Error while loading system library", szFilename));
- }
- catch(CRTException& ex) {
- ex.display();
+ lstrcatW(sysPathName, szFilename);
+ _h = LoadLibraryW(sysPathName);
+ if (0 == _h)
return 0;
- }
- return(_h);
+
+ return _h;
}
/**
@@ -1197,10 +1189,11 @@ static wchar_t* warnings[] = { LPGENT("Loading a theme|Loading a color and font theme can overwrite the settings defined by your skin.\n\nDo you want to continue?"), /* WARN_THEME_OVERWRITE */
};
-CWarning::CWarning(const wchar_t *tszTitle, const wchar_t *tszText, const UINT uId, const DWORD dwFlags)
+CWarning::CWarning(const wchar_t *tszTitle, const wchar_t *tszText, const UINT uId, const DWORD dwFlags) :
+ m_szTitle( mir_wstrdup(tszTitle)),
+ m_szText( mir_wstrdup(tszText))
+
{
- m_szTitle = new std::basic_string<wchar_t>(tszTitle);
- m_szText = new std::basic_string<wchar_t>(tszText);
m_uId = uId;
m_hFontCaption = 0;
m_dwFlags = dwFlags;
@@ -1391,7 +1384,7 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP mir_sntprintf(temp, 1024, RTF_DEFAULT_HEADER, 0, 0, 0, 30*15);
tstring *str = new tstring(temp);
- str->append(m_szText->c_str());
+ str->append(m_szText);
str->append(L"}");
TranslateDialogDefault(hwnd);
@@ -1409,7 +1402,7 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP mir_free(utf8);
delete str;
- ::SetDlgItemTextW(hwnd, IDC_CAPTION, m_szTitle->c_str());
+ ::SetDlgItemTextW(hwnd, IDC_CAPTION, m_szTitle);
if (m_dwFlags & CWF_NOALLOWHIDE)
Utils::showDlgControl(hwnd, IDC_DONTSHOWAGAIN, SW_HIDE);
|