aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2002-02-16 04:33:04 +0000
committernyamatongwe <devnull@localhost>2002-02-16 04:33:04 +0000
commitb524b63de67ab4a76f1dfd69f0dc16cb66680e93 (patch)
tree81dc48d08a2b6bacd183b019a2c911e8deaebb4b
parent4bab5bd86c9c69c7695be85a4a1fae0018f60b50 (diff)
downloadscintilla-mirror-b524b63de67ab4a76f1dfd69f0dc16cb66680e93.tar.gz
Windows classes unregistered at finalisation to avoid problems inside IE.
Success of initialisation and finalisationreturned to caller.
-rw-r--r--win32/ScintillaWin.cxx68
1 files changed, 41 insertions, 27 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index dfb81e894..239c166ba 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -90,6 +90,7 @@
// GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables.
+const char scintillaClassName[] = "Scintilla";
const char callClassName[] = "CallTip";
class ScintillaWin; // Forward declaration for COM interface subobjects
@@ -231,7 +232,9 @@ public:
void SetLexer(uptr_t wParam);
#endif
- static void Register(HINSTANCE hInstance_);
+ static bool Register(HINSTANCE hInstance_);
+ static bool Unregister();
+
friend class DropSource;
friend class DataObject;
friend class DropTarget;
@@ -1778,11 +1781,10 @@ STDMETHODIMP ScintillaWin::GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM) {
return S_OK;
}
-const char scintillaClassName[] = "Scintilla";
-
-void ScintillaWin::Register(HINSTANCE hInstance_) {
+bool ScintillaWin::Register(HINSTANCE hInstance_) {
hInstance = hInstance_;
+ bool result = true;
#if 0
// Register the Scintilla class
if (IsNT()) {
@@ -1818,28 +1820,36 @@ void ScintillaWin::Register(HINSTANCE hInstance_) {
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = scintillaClassName;
wndclass.hIconSm = 0;
- ::RegisterClassEx(&wndclass);
+ result = ::RegisterClassEx(&wndclass) != 0;
//}
- // Register the CallTip class
- WNDCLASSEX wndclassc;
- wndclassc.cbSize = sizeof(wndclass);
- wndclassc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
- wndclassc.cbClsExtra = 0;
- wndclassc.cbWndExtra = sizeof(ScintillaWin *);
- wndclassc.hInstance = hInstance;
- wndclassc.hIcon = NULL;
- wndclassc.hbrBackground = NULL;
- wndclassc.lpszMenuName = NULL;
- wndclassc.lpfnWndProc = ScintillaWin::CTWndProc;
- wndclassc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
- wndclassc.lpszClassName = callClassName;
- wndclassc.hIconSm = 0;
-
- if (!::RegisterClassEx(&wndclassc)) {
- //Platform::DebugPrintf("Could not register class\n");
- return;
+ if (result) {
+ // Register the CallTip class
+ WNDCLASSEX wndclassc;
+ wndclassc.cbSize = sizeof(wndclass);
+ wndclassc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
+ wndclassc.cbClsExtra = 0;
+ wndclassc.cbWndExtra = sizeof(ScintillaWin *);
+ wndclassc.hInstance = hInstance;
+ wndclassc.hIcon = NULL;
+ wndclassc.hbrBackground = NULL;
+ wndclassc.lpszMenuName = NULL;
+ wndclassc.lpfnWndProc = ScintillaWin::CTWndProc;
+ wndclassc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
+ wndclassc.lpszClassName = callClassName;
+ wndclassc.hIconSm = 0;
+
+ result = ::RegisterClassEx(&wndclassc) != 0;
}
+
+ return result;
+}
+
+bool ScintillaWin::Unregister() {
+ bool result = ::UnregisterClass(scintillaClassName, hInstance) != 0;
+ if (::UnregisterClass(callClassName, hInstance) == 0)
+ result = false;
+ return result;
}
sptr_t PASCAL ScintillaWin::CTWndProc(
@@ -1916,25 +1926,29 @@ extern void Platform_Finalise();
// This function is externally visible so it can be called from container when building statically.
// Must be called once only.
-void Scintilla_RegisterClasses(void *hInstance) {
+bool Scintilla_RegisterClasses(void *hInstance) {
Platform_Initialise(hInstance);
- ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance));
+ bool result = ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance));
#ifdef SCI_LEXER
LexerManager *lexMan = LexerManager::GetInstance();
lexMan->Load();
#endif
+ return result;
}
// This function is externally visible so it can be called from container when building statically.
-void Scintilla_ReleaseResources() {
+bool Scintilla_ReleaseResources() {
+ bool result = ScintillaWin::Unregister();
Platform_Finalise();
+ return result;
}
#ifndef STATIC_BUILD
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) {
//Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason);
if (dwReason == DLL_PROCESS_ATTACH) {
- Scintilla_RegisterClasses(hInstance);
+ if (!Scintilla_RegisterClasses(hInstance))
+ return FALSE;
} else if (dwReason == DLL_PROCESS_DETACH) {
Scintilla_ReleaseResources();
}