|
From: <got...@us...> - 2009-02-07 15:56:57
|
Revision: 192
http://scstudio.svn.sourceforge.net/scstudio/?rev=192&view=rev
Author: gotthardp
Date: 2009-02-07 15:56:51 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
Minor enhancement: Print error report when a DLL module cannot be loaded.
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/dllmodule.cpp
trunk/src/view/visio/addon/dllmodule.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/errors.cpp
trunk/src/view/visio/addon/errors.h
trunk/src/view/visio/addon/reportview.h
trunk/src/view/visio/addon/visualize.cpp
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/addon.cpp 2009-02-07 15:56:51 UTC (rev 192)
@@ -83,7 +83,7 @@
std::basic_string<TCHAR>::size_type uiPosition;
// Get the full path including the Addon name.
- GetModuleFileName(GetModuleHandle(LoadStringResource(IDS_VSL_NAME)),
+ GetModuleFileName(GetModuleHandle(LoadStringResource(IDS_VSL_NAME).c_str()),
szPath, sizeof(szPath) / sizeof(TCHAR));
// Extract the path name of the Addon.
Modified: trunk/src/view/visio/addon/dllmodule.cpp
===================================================================
--- trunk/src/view/visio/addon/dllmodule.cpp 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/dllmodule.cpp 2009-02-07 15:56:51 UTC (rev 192)
@@ -37,7 +37,7 @@
ATL::CStudioDllModule _AtlModule;
-_bstr_t LoadStringResource(UINT uiID)
+std::wstring LoadStringResource(UINT uiID)
{
// Get the module instance.
HINSTANCE hInstance = ATL::_AtlBaseModule.GetModuleInstance();
@@ -45,7 +45,7 @@
TCHAR szBuffer[100];
// Load the string from the string table.
LoadString(hInstance, uiID, szBuffer, sizeof(szBuffer) / sizeof(TCHAR));
- return _bstr_t(szBuffer);
+ return szBuffer;
}
std::wstring GetVersionInfo(const LPWSTR block)
Modified: trunk/src/view/visio/addon/dllmodule.h
===================================================================
--- trunk/src/view/visio/addon/dllmodule.h 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/dllmodule.h 2009-02-07 15:56:51 UTC (rev 192)
@@ -19,7 +19,7 @@
#pragma once
#include <string>
-_bstr_t LoadStringResource(UINT uiID);
+std::wstring LoadStringResource(UINT uiID);
std::wstring GetVersionInfo(const LPWSTR block);
// $Id$
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/document.cpp 2009-02-07 15:56:51 UTC (rev 192)
@@ -141,58 +141,67 @@
valNameLength = cchMaxValue+1;
valDataLength = cbMaxValueData+1;
- if(RegEnumValue(hSubKey, i,
+ long res = RegEnumValue(hSubKey, i,
valName,
&valNameLength,
NULL,
&dwType,
(LPBYTE)valData,
- &valDataLength) == ERROR_SUCCESS)
+ &valDataLength);
+
+ if(res != ERROR_SUCCESS)
+ continue;
+
+ // open the extension module
+ HINSTANCE module = LoadLibrary(valData);
+ if(module == NULL)
{
- // open the extension module
- HINSTANCE module = LoadLibrary(valData);
- if(module == NULL)
- continue;
+ DisplayException(m_vsoApp, basic_stringize<TCHAR>()
+ << _T("Cannot load module '") << valData << _T("'"), MB_OK | MB_ICONEXCLAMATION);
+ continue;
+ }
- FInitFormatters init_formatters = (FInitFormatters)GetProcAddress(module, "init_formatters");
- FInitCheckers init_checkers = (FInitCheckers)GetProcAddress(module, "init_checkers");
- if(init_formatters == NULL && init_checkers == NULL)
- {
- // this is not our module
- FreeLibrary(module);
- }
+ FInitFormatters init_formatters = (FInitFormatters)GetProcAddress(module, "init_formatters");
+ FInitCheckers init_checkers = (FInitCheckers)GetProcAddress(module, "init_checkers");
+ if(init_formatters == NULL && init_checkers == NULL)
+ {
+ DisplayException(m_vsoApp, basic_stringize<TCHAR>()
+ << _T("Cannot open module '") << valData << _T("'"), MB_OK | MB_ICONEXCLAMATION);
+ // this is not our module
+ FreeLibrary(module);
+ continue;
+ }
- if(init_formatters != NULL)
+ if(init_formatters != NULL)
+ {
+ Formatter **formatters = init_formatters();
+ // append new formatters to the list
+ for(Formatter **fpos = formatters; *fpos != NULL; fpos++)
{
- Formatter **formatters = init_formatters();
- // append new formatters to the list
- for(Formatter **fpos = formatters; *fpos != NULL; fpos++)
- {
- boost::shared_ptr<Formatter> formatter(*fpos);
- m_formatters.push_back(formatter);
- }
- // delete the array
- // note: the formatters are managed by the boost:shared_ptr
- delete[] formatters;
+ boost::shared_ptr<Formatter> formatter(*fpos);
+ m_formatters.push_back(formatter);
}
+ // delete the array
+ // note: the formatters are managed by the boost:shared_ptr
+ delete[] formatters;
+ }
- if(init_checkers != NULL)
+ if(init_checkers != NULL)
+ {
+ Checker **checkers = init_checkers();
+ // append new checkers to the list
+ for(Checker **fpos = checkers; *fpos != NULL; fpos++)
{
- Checker **checkers = init_checkers();
- // append new checkers to the list
- for(Checker **fpos = checkers; *fpos != NULL; fpos++)
- {
- boost::shared_ptr<Checker> checker(*fpos);
- m_checkers.push_back(checker);
- }
- // delete the array
- // note: the checkers are managed by the boost:shared_ptr
- delete[] checkers;
+ boost::shared_ptr<Checker> checker(*fpos);
+ m_checkers.push_back(checker);
}
+ // delete the array
+ // note: the checkers are managed by the boost:shared_ptr
+ delete[] checkers;
+ }
- // keep the pointer to properly unload the module
- m_open_modules.push_back(module);
- }
+ // keep the pointer to properly unload the module
+ m_open_modules.push_back(module);
}
delete[] valName;
@@ -662,7 +671,7 @@
const int defWidth = 500;
const int defHeight = 150;
- m_reportWindow = vsoWindow->Windows->Add(LoadStringResource(IDS_REPORT_VIEW),
+ m_reportWindow = vsoWindow->Windows->Add(LoadStringResource(IDS_REPORT_VIEW).c_str(),
Visio::visWSVisible | Visio::visWSAnchorLeft, Visio::visAnchorBarAddon, 1, 1, defWidth, defHeight);
LoadLibrary(CRichEditCtrl::GetLibraryName());
Modified: trunk/src/view/visio/addon/errors.cpp
===================================================================
--- trunk/src/view/visio/addon/errors.cpp 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/errors.cpp 2009-02-07 15:56:51 UTC (rev 192)
@@ -23,14 +23,14 @@
#include <string>
void DisplayException(Visio::IVApplicationPtr vsoApp,
- const _bstr_t& bstrMessage, UINT nFlags)
+ const std::wstring& bstrMessage, UINT nFlags)
{
if (vsoApp->GetAlertResponse() == 0)
{
- MessageBox(GetActiveWindow(), bstrMessage, LoadStringResource(IDS_ADDON_NAME), nFlags);
+ MessageBox(GetActiveWindow(), bstrMessage.c_str(), LoadStringResource(IDS_ADDON_NAME).c_str(), nFlags);
}
else
- OutputDebugString(bstrMessage);
+ OutputDebugString(bstrMessage.c_str());
}
// $Id$
Modified: trunk/src/view/visio/addon/errors.h
===================================================================
--- trunk/src/view/visio/addon/errors.h 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/errors.h 2009-02-07 15:56:51 UTC (rev 192)
@@ -32,6 +32,6 @@
#endif
void DisplayException(Visio::IVApplicationPtr vsoApp,
- const _bstr_t& bstrMessage, UINT nFlags);
+ const std::wstring& bstrMessage, UINT nFlags);
// $Id$
Modified: trunk/src/view/visio/addon/reportview.h
===================================================================
--- trunk/src/view/visio/addon/reportview.h 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/reportview.h 2009-02-07 15:56:51 UTC (rev 192)
@@ -60,25 +60,28 @@
/*!
* reporter->Print(stringize() << "string" << number);
*/
-struct stringize
+template<typename C>
+struct basic_stringize
{
- template< typename T >
- stringize & operator << (T const& t)
+ template<typename T>
+ basic_stringize<C> & operator << (T const& t)
{
m_s << t;
return *this;
}
// note: must not return reference
- operator const std::string() const
+ operator const std::basic_string<C>() const
{
return m_s.str();
}
private:
- std::stringstream m_s;
+ std::basic_stringstream<C> m_s;
};
+typedef basic_stringize<char> stringize;
+
struct shapelist
{
shapelist & operator << (Visio::IVShapePtr shape)
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2009-02-05 23:03:27 UTC (rev 191)
+++ trunk/src/view/visio/addon/visualize.cpp 2009-02-07 15:56:51 UTC (rev 192)
@@ -49,7 +49,7 @@
}
catch (_com_error&)
{
- DisplayException(vsoApp, "Bad template or stencils. Visualization failed.", MB_OK);
+ DisplayException(vsoApp, _T("Bad template or stencils. Visualization failed."), MB_OK);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|