[vtkusers] Invalid index for GetWindowLongPtr in vtkWin32RenderWindowInteractor ? (x64)
gerndt at rz.rwth-aachen.de
Mon Aug 14 09:01:49 EDT 2006
Get/SetWindowLongPtr can also be used to address extra
memory assigned to a window. Therefore, 4 means that the
funtion gets data starting at an offset of 4 in this
block of extra memory.
VTK uses this data to hold the pointer to the originally
instantiated render window object. The first 4 bytes are
reserved for the application. This is only useful when
handling 32-bit long pointers. For 64-bit applications,
the size should be enhanced to 8 bytes.
The main problem, however, is that only 8 bytes in total
for application and VTK is allocated. Therefore, the first
action should be increasing the extra memory size of the
wndClass.cbWndExtra = 16;
This should already help!
A more generic approach would be to add an offset variable
into the code block embraced by "#if ( _MSC_VER >= 1300 )"
at the beginning of this source file:
#if ( _MSC_VER >= 1300 ) // Visual studio .NET
#pragma warning ( disable : 4311 )
#pragma warning ( disable : 4312 )
# define vtkGWLP_HINSTANCE GWLP_HINSTANCE
# define vtkWndOffset sizeof(LONG_PTR)
# define vtkGetWindowLong GetWindowLongPtr
# define vtkSetWindowLong SetWindowLongPtr
#else // regular Visual studio
# define vtkGWLP_HINSTANCE GWL_HINSTANCE
# define vtkWndOffset sizeof(LONG)
# define vtkGetWindowLong GetWindowLong
# define vtkSetWindowLong SetWindowLong
The extar window memory allocation could modified as
wndClass.cbWndExtra = 2 * vtkWndOffset;
Than replace all 4s in "vtkGetWindowLong(this->WindowId,4)"
as well as "vtkSetWindowLong(this->WindowId,4,(LONG)...);"
with vtkWndOffset. The affected files are:
- "vtkTKRenderWidget.cxx", and
Another recommendation could be replacing all (LONG)-castings
with (LONG_PTR) (which might be problematic for older studio
> -----Original Message-----
> From: vtkusers-bounces+gerndt=rz.rwth-aachen.de at vtk.org
> [mailto:vtkusers-bounces+gerndt=rz.rwth-aachen.de at vtk.org] On
> Behalf Of Thomas Lambertz
> Sent: Saturday, May 13, 2006 3:08 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Invalid index for GetWindowLongPtr in
> vtkWin32RenderWindowInteractor ? (x64)
> i tried to find a way to make vtkRenderWindowInteractor work under
> Windows x64. To be honest - i am not very familiar with the
> Windows API
> - so if i am talking rubbish please be patient...
> I tried to isolate why there is no render-output when i used
> vtkWindowRenderInteractor under x64. A good example are the
> tutorials in
> vtk/Example/Tutorial. Step 1-4 are working properly as the render
> "manually" - step 5-6 have changed to vtkWindowRenderInteractor and
> doesnt work.
> Adding some debug-output i saw that the Render() method wasnt
> invoked -
> so no surprise that there is only a black Windows ;-)
> Searching in vtkWin32RenderWindowInteractor and
> vtkWin32OpenGLRenderWindow i found Code like this:
> The returned Pointer/Handle is NULL and GetLastError() gives an Error
> 1413 which means invalid index. As i understand "4" ist the wrong
> parameter. Excerpt from Winuser.h:
> * Window field offsets for GetWindowLong()
> #define GWLP_WNDPROC (-4)
> #define GWLP_HINSTANCE (-6)
> #define GWLP_HWNDPARENT (-8)
> #define GWLP_USERDATA (-21)
> #define GWLP_ID (-12)
> I assumed GWLP_WNDPROC was intended and i changed the Code in
> that way.
> But that is not the solution - now i get this errormessage:
> ERROR: In
> ..\..\vtk5.0_64\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 809
> vtkWin32OpenGLRenderWindow (0000000000366F40): Could not
> create window,
> error: 0
> And consistently there is no output-window...
> Sorry for making a such great hullabaloo. I hope that someone
> else can
> grab this information to become more succesful to solve this problem.
> kind regards,
> PS: Under win32 the correspondent GWL_WINPROC is also defined
> as (-4) -
> but this does not seemes to make Problems (i havent investigate this
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> Follow this link to subscribe/unsubscribe:
More information about the vtkusers