How to Embed a 3D HOOPS view in MFC Dialog Based App?

How to Embed a 3D HOOPS view in MFC Dialog Based App?

In this blog article, I will show you a simple way to embed a HOOPS 3D Part viewer inside MFC (Microsoft Foundation Classes) dialog.

HOOPS MFC was designed around the MFC SDI & MDI architecture (i.e. Document, Frame and View) but dialog based MFC application have only one dialog and there is no view, no document and no frame.

To embed a HOOPS view inside such an application, follow the steps below :-

1. Add a Picture Control object from the Toolbox. Make sure that the picture control ‘Visible’ attribute is set to true. Save the changes.
2. Add the OnInitDialog() function, and add an OnPaint message handler in the dialog class.
3. Modify the body of the OnPaint function, and implement the OnInitDialog() function as shown below:

A. Implement OnInitDialog() as follows.

  • Create a HOOPS MVO model and call its initialization function.
  • Retrieve the window handle.
  • Create a HOOPS MVO view with the window handle and the model created in earlier steps. Use any driver you want. I had used OpenGL for simplicity of the prerequisites.
  • Call the initialization function of the HOOPS MVO function.
  • Now the HOOPS View is prepared and ready for rendering.

B. Implement the OnPaint() method which is a message handler and update the HOOPS MVO view in this method.*Note : Unless this you can’t render anything.
4. After saving and rebuilding, you should see that the dialog box created will contain a HOOPS scene.

Author : Sanyogita
Contact us:
ProtoTech Solutions