
This patch fixes a few small problems in Tk8.2.0 and
Tk 8.2.1 which will hopefully be solved in later
versions. They only involve the Windows platform.

- The function TkWinXInit() should be called when Tk is
  compiled as a static library.
- The function TkWinGetPlatformId should be moved from
  TkWin32Dll.c to TkWinX.c. Otherwise when creating a
  static library we don't have the possibility to leave
  out DllMain, because TkWinGetPlatformId will be left
  out together with it.
- It is not necessary to have both a DllMain and a
  DllEntryPoint function. With a proper macro both
  functions can be merged in a single one which works
  on VC++, Borland and (as extra bonus) with gcc as well.

           Jan Nijtmans              Jan.Nijtmans@wxs.nl

*** generic/tkWindow.c.orig	Wed Apr 21 23:53:28 1999
--- generic/tkWindow.c	Sat Sep 25 19:39:12 1999
***************
*** 21,26 ****
--- 21,29 ----
  #if !defined(__WIN32__) && !defined(MAC_TCL)
  #include "tkUnixInt.h"
  #endif
+ #if defined(__WIN32__)
+ #include "tkWinInt.h"
+ #endif
  
  
  typedef struct ThreadSpecificData {
***************
*** 2709,2714 ****
--- 2712,2727 ----
      Tcl_DString class;
      ThreadSpecificData *tsdPtr;
      
+ #if defined(__WIN32__) && defined(STATIC_BUILD) && !defined(NO_STATIC_INIT)
+     /*
+      * If we are in a statically linked executable, then we need to
+      * explicitly initialize the Windows function tables here since
+      * DllMain() will not be invoked.
+      */
+ 
+     TkWinXInit(GetModuleHandle(NULL));
+ #endif
+ 
      /*
       * Ensure that we are getting the matching version of Tcl.  This is
       * really only an issue when Tk is loaded dynamically.
*** win/tkWin32Dll.c.orig	Fri Apr 16 03:51:48 1999
--- win/tkWin32Dll.c	Sat Sep 25 19:33:35 1999
***************
*** 13,26 ****
  
  #include "tkWinInt.h"
  
! static int tkPlatformId;
  
- /*
-  * The following declaration is for the VC++ DLL entry point.
-  */
- 
- BOOL APIENTRY		DllMain _ANSI_ARGS_((HINSTANCE hInst,
- 			    DWORD reason, LPVOID reserved));
  
  /*
   *----------------------------------------------------------------------
--- 13,22 ----
  
  #include "tkWinInt.h"
  
! #if defined(_MSC_VER) || defined(__GNUC__)
! #define DllEntryPoint DllMain
! #endif
  
  
  /*
   *----------------------------------------------------------------------
***************
*** 32,63 ****
   *	routine.
   *
   * Results:
!  *	See DllMain.
!  *
!  * Side effects:
!  *	See DllMain.
!  *
!  *----------------------------------------------------------------------
!  */
! 
! BOOL APIENTRY
! DllEntryPoint(hInst, reason, reserved)
!     HINSTANCE hInst;		/* Library instance handle. */
!     DWORD reason;		/* Reason this function is being called. */
!     LPVOID reserved;		/* Not used. */
! {
!     return DllMain(hInst, reason, reserved);
! }
! 
! /*
!  *----------------------------------------------------------------------
!  *
!  * DllMain --
!  *
!  *	DLL entry point.
!  *
!  * Results:
!  *	TRUE on sucess, FALSE on failure.
   *
   * Side effects:
   *	None.
--- 28,34 ----
   *	routine.
   *
   * Results:
!  *	TRUE on success, FALSE otherwise.
   *
   * Side effects:
   *	None.
***************
*** 66,77 ****
   */
  
  BOOL APIENTRY
! DllMain(hInstance, reason, reserved)
!     HINSTANCE hInstance;
!     DWORD reason;
!     LPVOID reserved;
  {
-     OSVERSIONINFO os;
  
      /*
       * If we are attaching to the DLL from a new process, tell Tk about
--- 37,47 ----
   */
  
  BOOL APIENTRY
! DllEntryPoint (
!     HINSTANCE hInstance,	/* Library instance handle. */
!     DWORD reason,		/* Reason this function is being called. */
!     LPVOID reserved)		/* Not used. */
  {
  
      /*
       * If we are attaching to the DLL from a new process, tell Tk about
***************
*** 80,119 ****
       */
      
      if (reason == DLL_PROCESS_ATTACH) {
- 	os.dwOSVersionInfoSize = sizeof(os);
- 	GetVersionEx(&os);
- 	tkPlatformId = os.dwPlatformId;
- 
          TkWinXInit(hInstance);
      } else if (reason == DLL_PROCESS_DETACH) {
          TkWinXCleanup(hInstance);
      }
      return(TRUE);
  }
- 
- /*
-  *----------------------------------------------------------------------
-  *
-  * TkWinGetPlatformId --
-  *
-  *	Determines whether running under NT, 95, or Win32s, to allow 
-  *	runtime conditional code.
-  *
-  * Results:
-  *	The return value is one of:
-  *	    VER_PLATFORM_WIN32s		Win32s on Windows 3.1. 
-  *	    VER_PLATFORM_WIN32_WINDOWS	Win32 on Windows 95.
-  *	    VER_PLATFORM_WIN32_NT	Win32 on Windows NT
-  *
-  * Side effects:
-  *	None.
-  *
-  *----------------------------------------------------------------------
-  */
- 
- int		
- TkWinGetPlatformId()
- {
-     return tkPlatformId;
- }
- 
--- 50,58 ----
*** win/tkWinX.c.orig	Fri Jul  9 04:10:07 1999
--- win/tkWinX.c	Sat Sep 25 19:33:35 1999
***************
*** 26,31 ****
--- 26,32 ----
   */
  
  int tkpIsWin32s = -1;
+ static int tkPlatformId;
  
  /*
   * Declarations of static variables used in this file.
***************
*** 142,148 ****
  
      info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
      GetVersionEx(&info);
!     tkpIsWin32s = (info.dwPlatformId == VER_PLATFORM_WIN32s);
  
      if (childClassInitialized != 0) {
  	return;
--- 143,150 ----
  
      info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
      GetVersionEx(&info);
!     tkPlatformId = info.dwPlatformId;
!     tkpIsWin32s = (tkPlatformId == VER_PLATFORM_WIN32s);
  
      if (childClassInitialized != 0) {
  	return;
***************
*** 1132,1132 ****
--- 1134,1161 ----
  }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
+  * TkWinGetPlatformId --
+  *
+  *	Determines whether running under NT, 95, or Win32s, to allow 
+  *	runtime conditional code.
+  *
+  * Results:
+  *	The return value is one of:
+  *	    VER_PLATFORM_WIN32s		Win32s on Windows 3.1. 
+  *	    VER_PLATFORM_WIN32_WINDOWS	Win32 on Windows 95.
+  *	    VER_PLATFORM_WIN32_NT	Win32 on Windows NT
+  *
+  * Side effects:
+  *	None.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ int		
+ TkWinGetPlatformId()
+ {
+     return tkPlatformId;
+ }
+ 
