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 | |
parent | 14fa6ff7baf4b7691eca6a41e756c5d3375ad000 (diff) |
minus some horrors in tabs
git-svn-id: http://svn.miranda-ng.org/main/trunk@5760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/TabSRMM/src/globals.cpp | 17 | ||||
-rw-r--r-- | plugins/TabSRMM/src/globals.h | 13 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themes.cpp | 11 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 69 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.h | 5 |
5 files changed, 36 insertions, 79 deletions
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 98b0420e07..9827acaa07 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -74,23 +74,6 @@ bool CGlobals::m_exAllowContinue = false; static char *szFLVersionUrl = "http://miranda-ng.org/";
static char *szFLUpdateurl = "http://miranda-ng.org/";
#endif
- static char *szPrefix = "tabsrmm ";
-
-
-CRTException::CRTException(const char *szMsg, const TCHAR *szParam) : std::runtime_error(std::string(szMsg))
-{
- mir_sntprintf(m_szParam, MAX_PATH, szParam);
-}
-
-void CRTException::display() const
-{
- TCHAR* tszMsg = mir_a2t(what());
- TCHAR tszBoxMsg[500];
-
- mir_sntprintf(tszBoxMsg, 500, _T("%s\n\n(%s)"), tszMsg, m_szParam);
- ::MessageBox(0, tszBoxMsg, _T("TabSRMM runtime error"), MB_OK | MB_ICONERROR);
- mir_free(tszMsg);
-}
/**
* reload system values. These are read ONCE and are not allowed to change
diff --git a/plugins/TabSRMM/src/globals.h b/plugins/TabSRMM/src/globals.h index e063312726..a45c18bac3 100644 --- a/plugins/TabSRMM/src/globals.h +++ b/plugins/TabSRMM/src/globals.h @@ -45,19 +45,6 @@ struct TSplitterBroadCast { typedef BOOL (WINAPI *pfnSetMenuInfo )( HMENU hmenu, LPCMENUINFO lpcmi );
-class CRTException : public std::runtime_error
-{
-public:
- CRTException(const char *szMsg, const TCHAR *szParam);
- ~CRTException() {}
-
- void display() const;
-
-private:
- TCHAR m_szParam[MAX_PATH];
-};
-
-
class CGlobals
{
public:
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index d1c97d4276..823fa43b0e 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -2555,14 +2555,9 @@ void CSkin::extractSkinsAndLogo(bool fForceOverwrite) const m_fAeroSkinsValid = true;
- try {
- for (int i=0; i < SIZEOF(my_default_skin); i++)
- Utils::extractResource(g_hInst, my_default_skin[i].ulID, _T("SKIN_GLYPH"), tszBasePath, my_default_skin[i].tszName, fForceOverwrite);
- }
- catch(CRTException& ex) {
- ex.display();
- m_fAeroSkinsValid = false;
- }
+ for (int i=0; i < SIZEOF(my_default_skin); i++)
+ if ( !Utils::extractResource(g_hInst, my_default_skin[i].ulID, _T("SKIN_GLYPH"), tszBasePath, my_default_skin[i].tszName, fForceOverwrite))
+ m_fAeroSkinsValid = false;
}
/**
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);
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index 8254dbf6dc..eca81a3ccd 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -96,7 +96,7 @@ public: static HICON TSAPI iconFromAvatar (const TWindowData *dat);
static void TSAPI getIconSize (HICON hIcon, int& sizeX, int& sizeY);
- static void TSAPI extractResource (const HMODULE h, const UINT uID, const TCHAR *tszName, const TCHAR *tszPath,
+ static bool TSAPI extractResource (const HMODULE h, const UINT uID, const TCHAR *tszName, const TCHAR *tszPath,
const TCHAR *tszFilename, bool fForceOverwrite);
static void TSAPI scaleAvatarHeightLimited (const HBITMAP hBm, double& dNewWidth, double& dNewHeight, const LONG maxHeight);
@@ -247,8 +247,7 @@ public: LRESULT ShowDialog () const;
private:
- std::basic_string<wchar_t>* m_szTitle;
- std::basic_string<wchar_t>* m_szText;
+ ptrT m_szTitle, m_szText;
UINT m_uId;
HFONT m_hFontCaption;
DWORD m_dwFlags;
|