Index: Rendering/vtkTkImageViewerWidget.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkTkImageViewerWidget.cxx,v
retrieving revision 1.73
diff -u -r1.73 vtkTkImageViewerWidget.cxx
--- Rendering/vtkTkImageViewerWidget.cxx	15 Sep 2004 02:23:31 -0000	1.73
+++ Rendering/vtkTkImageViewerWidget.cxx	22 Nov 2004 16:06:42 -0000
@@ -18,6 +18,15 @@
 #include "vtkRenderWindowInteractor.h"
 #include "vtkTkInternals.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 _MSC_VER
  #pragma warning ( disable : 4273 )
 #else
@@ -402,8 +411,26 @@
           {
           SetWindowLong((HWND)self->ImageViewer->GetRenderWindow()->GetGenericWindowId(),
                         GWL_USERDATA,(LONG)((TkWindow *)self->TkWin)->window);
+
+        #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;
+        }
+          SetWindowLong((HWND)self->ImageViewer->GetRenderWindow()->GetGenericWindowId(),
+                        GWL_WNDPROC,(LONG)tkWinChildProc);
+        #else 
           SetWindowLong((HWND)self->ImageViewer->GetRenderWindow()->GetGenericWindowId(),
                         GWL_WNDPROC,(LONG)TkWinChildProc);
+        #endif
+
+
           }
 #endif
         Tcl_EventuallyFree( (ClientData) self, vtkTkImageViewerWidget_Destroy );
@@ -457,8 +484,23 @@
   vtkSetWindowLong(hWnd,GWL_USERDATA,(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
     {
@@ -514,8 +556,23 @@
             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
     }
 
