summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-12-08 00:46:51 (GMT)
committerhobbs <hobbs>2002-12-08 00:46:51 (GMT)
commit9ba6b47ef626dc8248e5fcd5a420d332baeaae53 (patch)
tree0980b63dd1bf1aabca841a318efcd6eaf6102981 /win
parentdf50e6eb7fcee1b7b60c7dc9c0d1968124197b9e (diff)
downloadtk-9ba6b47ef626dc8248e5fcd5a420d332baeaae53.zip
tk-9ba6b47ef626dc8248e5fcd5a420d332baeaae53.tar.gz
tk-9ba6b47ef626dc8248e5fcd5a420d332baeaae53.tar.bz2
* generic/tkInt.decls: add TkWinSetHINSTANCE decl
* generic/tkIntPlatDecls.h: regen * generic/tkStubInit.c: regen * win/tkWinInit.c (TkpInit): While init and cleanup aren't correct * win/tkWinX.c (TkWinXInit): in DllMain, we had to specify the * win/tkWin32Dll.c (DllMain): true HINSTANCE or the resources of a dynamic Tk weren't being loaded correctly. Created a new function TkWinSetHINSTANCE for this purpose.
Diffstat (limited to 'win')
-rw-r--r--win/tkWin32Dll.c18
-rw-r--r--win/tkWinInit.c9
-rw-r--r--win/tkWinX.c33
3 files changed, 46 insertions, 14 deletions
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index c8e03c1..4570a5a 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin32Dll.c,v 1.5 2002/12/06 23:29:37 hobbs Exp $
+ * RCS: @(#) $Id: tkWin32Dll.c,v 1.6 2002/12/08 00:46:51 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -52,10 +52,10 @@ DllEntryPoint(hInst, reason, reserved)
*
* DllMain --
*
- * DLL entry point. It is not necessary to do anything here as
- * Tk will initialize and clean up after itself through other
- * methods, in order to be consistent whether the build is static
- * or dynamic.
+ * DLL entry point. It is only necessary to specify our dll here so
+ * that resources are found correctly. Otherwise Tk will initialize
+ * and clean up after itself through other methods, in order to be
+ * consistent whether the build is static or dynamic.
*
* Results:
* Always TRUE.
@@ -72,5 +72,13 @@ DllMain(hInstance, reason, reserved)
DWORD reason;
LPVOID reserved;
{
+ /*
+ * If we are attaching to the DLL from a new process, tell Tk about
+ * the hInstance to use.
+ */
+
+ if (reason == DLL_PROCESS_ATTACH) {
+ TkWinSetHINSTANCE(hInstance);
+ }
return (TRUE);
}
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index fec211b..1ec2642 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinInit.c,v 1.9 2002/04/12 07:18:49 hobbs Exp $
+ * RCS: @(#) $Id: tkWinInit.c,v 1.10 2002/12/08 00:46:51 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -44,11 +44,10 @@ TkpInit(interp)
Tcl_Interp *interp;
{
/*
- * This is necessary for static initialization, and is ok
- * otherwise because TkWinXInit flips a static bit to do
- * its work just once.
+ * This is necessary for static initialization, and is ok otherwise
+ * because TkWinXInit flips a static bit to do its work just once.
*/
- TkWinXInit(GetModuleHandle(NULL));
+ TkWinXInit(Tk_GetHINSTANCE());
return Tcl_Eval(interp, initScript);
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index f97db04..ae21e4b 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.24 2002/12/06 23:29:37 hobbs Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.25 2002/12/08 00:46:51 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -76,7 +76,7 @@ TkWinProcs *tkWinProcs;
*/
static char winScreenName[] = ":0"; /* Default name of windows display. */
-static HINSTANCE tkInstance; /* Application instance handle. */
+static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized; /* Registered child class? */
static WNDCLASS childClass; /* Window class for child windows. */
static int tkPlatformId = 0; /* version of Windows platform */
@@ -171,12 +171,39 @@ TkGetServerInfo(interp, tkwin)
HINSTANCE
Tk_GetHINSTANCE()
{
+ if (tkInstance == NULL) {
+ tkInstance = GetModuleHandle(NULL);
+ }
return tkInstance;
}
/*
*----------------------------------------------------------------------
*
+ * TkWinSetHINSTANCE --
+ *
+ * Sets the global instance handle used by the Tk library.
+ * This should be called by DllMain.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkWinSetHINSTANCE(hInstance)
+ HINSTANCE hInstance;
+{
+ tkInstance = hInstance;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkWinXInit --
*
* Initialize Xlib emulation layer.
@@ -214,8 +241,6 @@ TkWinXInit(hInstance)
tkWinProcs = &asciiProcs;
}
- tkInstance = hInstance;
-
/*
* When threads are enabled, we cannot use CLASSDC because
* threads will then write into the same device context.