[vtkusers] VTK in an MFC dialog application
Philippe Bruyant
pbruyant at yahoo.com
Sun Nov 11 11:54:29 EST 2007
Hello VTK users,
I am using VTK 5.0, MS Visual Studio 6.0 and Win Vista.
I have the following problem:
I want to display a 3D scene in a static control (CStatic) in a dialog box.
In the OnInitDialog() of my dialog box class, I insert the code below,
but it crashes at the last line, when it's time to delete the renderer window.
My question is: am I using SetParentId() correctly?
Thank you,
Philippe
////////////////////////////////////////////////////////////////////////////////////////////////////
CStatic *pStatic=(CStatic *)GetDlgItem(IDC_STATIC);
vtkConeSource *cone = vtkConeSource::New();
cone->SetHeight( 3.0 );
cone->SetRadius( 1.0 );
cone->SetResolution( 10 );
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkRenderer *ren1= vtkRenderer::New();
ren1->AddActor( coneActor );
ren1->SetBackground( 0.1, 0.2, 0.4 );
vtkRenderWindow *renWin = vtkRenderWindow::New();
// Attach the VTK scene to the static control
renWin->SetParentId(pStatic->m_hWnd);
renWin->AddRenderer( ren1 );
renWin->SetSize( 300, 300 );
renWin->Render();
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071111/476ca35a/attachment.htm>
More information about the vtkusers
mailing list