[vtk-developers] Linking a VTK viewer in MFC Application

David Cole david.cole at kitware.com
Wed Nov 16 06:56:47 EST 2011


The sample in VTK/Examples/GUI/Win32/SampleMFC shows the following
code in vtkMFCRenderView.cpp:

int vtkMFCRenderView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (vtkMFCView::OnCreate(lpCreateStruct) == -1)
    return -1;

  // TODO: Add your specialized creation code here
  this->RenderWindow->SetParentId(lpCreateStruct->hwndParent);

  return 0;
}

This, and other code in that class, makes the VTK render window occupy
the client area of the MFC view. You have to put a parent window
around the VTK window in order to do what you want. And then deal with
making sure resizing, focus and keyboard events are properly handled.
It's not trivially easy, but it's do-able.


HTH,
David


On Wed, Nov 16, 2011 at 6:47 AM, Sridhar Ponnangatti Masilamani
<Sridhar.Masilamani at hcl.com> wrote:
> Hi David,
>
> I have gone through the specified examples and was able to get the output.
>
> I am able to get a VTK Viewer and also a MFC window. I am displaying two windows.
>
>
> My question is  can we integrate a VTK viewer window into a picture control of a MFC application i.e. I want the VTK viewer to be displayed in a single window not displaying as two separate windows?
>
>
>
>
>
>
> -----Original Message-----
> From: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org] On Behalf Of David Cole
> Sent: Wednesday, November 16, 2011 5:08 PM
> To: Sridhar Ponnangatti Masilamani
> Cc: vtk-developers at vtk.org
> Subject: Re: [vtk-developers] Linking a VTK viewer in MFC Application
>
> Please see the MFC related examples in VTK/Examples/GUI/Win32.
>
> Adding your ITK support to an app based on one of those examples
> should be a good start.
>
>
> HTH,
> David
>
> On Wed, Nov 16, 2011 at 12:49 AM, Sridhar Ponnangatti Masilamani
> <Sridhar.Masilamani at hcl.com> wrote:
>> Hi,
>>
>>
>>
>> I have made a application in which I read an image using ITK, display it in
>> VTK viewer.
>>
>> I have combined the above two in a MFC Single Document application.
>>
>>
>>
>> So when I click a button on GUI,
>>
>>
>>
>> The image is read in ITK and displayed using a VTK viewer.
>>
>>
>>
>> My concern is I am getting two separate windows i.e. one for the MFC and the
>> other the VTK viewer.
>>
>>
>>
>> Can we combine the VTK Viewer into an MFC GUI i.e. I want to embed that VTK
>> viewer my MFC. I don't want two separate windows coming up.
>>
>>
>>
>> Please provide some suggestions on this.
>>
>>
>>
>>
>>
>> Regards,
>>
>> Sridhar.
>>
>> ________________________________
>> ::DISCLAIMER::
>> -----------------------------------------------------------------------------------------------------------------------
>>
>> The contents of this e-mail and any attachment(s) are confidential and
>> intended for the named recipient(s) only.
>> It shall not attach any liability on the originator or HCL or its
>> affiliates. Any views or opinions presented in
>> this email are solely those of the author and may not necessarily reflect
>> the opinions of HCL or its affiliates.
>> Any form of reproduction, dissemination, copying, disclosure, modification,
>> distribution and / or publication of
>> this message without the prior written consent of the author of this e-mail
>> is strictly prohibited. If you have
>> received this email in error please delete it and notify the sender
>> immediately. Before opening any mail and
>> attachments please check them for viruses and defect.
>>
>> -----------------------------------------------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list