Index: Rendering/vtkTkRenderWidget.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkTkRenderWidget.cxx,v
retrieving revision 1.104
diff -u -r1.104 vtkTkRenderWidget.cxx
--- Rendering/vtkTkRenderWidget.cxx	11 Sep 2004 14:55:16 -0000	1.104
+++ Rendering/vtkTkRenderWidget.cxx	22 Nov 2004 16:14:08 -0000
@@ -22,6 +22,15 @@
 #include "vtkToolkits.h"
 
 #ifdef _WIN32
+  #ifdef USE_TCL_STUBS
+    static WNDCLASS childClass;	    /* Window class for child windows. */
+    static LRESULT (CALLBACK *tkWinChildProc)(HWND hwnd, UINT message,
+				 WPARAM wParam, LPARAM lParam) = NULL;
+    #define TK_WIN_CHILD_CLASS_NAME "TkChild"
+  #endif 
+#endif
+
+#ifdef _WIN32
 #include "vtkWin32OpenGLRenderWindow.h"
 #else
 #ifdef VTK_USE_CARBON
@@ -710,7 +719,6 @@
 // Here is the windows specific code for creating the window
 // The Xwindows version follows after this
 #ifdef _WIN32
-
 LRESULT APIENTRY vtkTkRenderWidgetProc(HWND hWnd, UINT message, 
                                        WPARAM wParam, LPARAM lParam)
 {
@@ -747,8 +755,23 @@
   vtkSetWindowLong(hWnd,4,(LONG)((TkWindow *)self->TkWin)->window);
   if (((TkWindow *)self->TkWin)->parentPtr)
     {
-    vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)TkWinChildProc);
-    rval = TkWinChildProc(hWnd,message,wParam,lParam);
+    #if USE_TCL_STUBS
+        /*
+         * OK, since TkWinChildProc is not explicitly exported in the
+         * dynamic libraries (stubs table), we have to retrieve it from the class info
+         * registered with windows.
+         * kudos: http://cvs.sourceforge.net/viewcvs.py/togl/Togl/togl.c?rev=1.57
+         */
+        if (tkWinChildProc == NULL) {
+           GetClassInfo(Tk_GetHINSTANCE(),TK_WIN_CHILD_CLASS_NAME,&childClass);
+           tkWinChildProc = childClass.lpfnWndProc;
+        }
+      vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)tkWinChildProc);
+      rval = tkWinChildProc(hWnd, message, wParam, lParam);
+    #else
+      vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)TkWinChildProc);
+      rval = TkWinChildProc(hWnd,message,wParam,lParam);
+    #endif
     }
   else
     {
@@ -800,8 +823,24 @@
             Tcl_ServiceAll();
             return 0;
       }
-    vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)TkWinChildProc);
-    rval = TkWinChildProc(hWnd,message,wParam,lParam);
+
+    #if USE_TCL_STUBS
+        /*
+         * OK, since TkWinChildProc is not explicitly exported in the
+         * dynamic libraries (stubs table), we have to retrieve it from the class info
+         * registered with windows.
+         * kudos: http://cvs.sourceforge.net/viewcvs.py/togl/Togl/togl.c?rev=1.57
+         */
+        if (tkWinChildProc == NULL) {
+           GetClassInfo(Tk_GetHINSTANCE(),TK_WIN_CHILD_CLASS_NAME,&childClass);
+           tkWinChildProc = childClass.lpfnWndProc;
+        }
+      vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)tkWinChildProc);
+      rval = tkWinChildProc(hWnd, message, wParam, lParam);
+    #else
+      vtkSetWindowLong(hWnd,GWL_WNDPROC,(LONG)TkWinChildProc);
+      rval = TkWinChildProc(hWnd,message,wParam,lParam);
+    #endif
 #endif
     }
 
