Open Inventor FAQs - Microsoft Windows

[Win32] How can we have a popup menu (right mouse context menu) in the Open Inventor window? Messages such as mouse right button down (WM_RBUTTONDOWN) seem to be hidden by Open Inventor.

You're right, although Inventor isn't really "hiding" anything. The Inventor viewers automatically size themselves to exactly cover their parent window. This is very convenient because it allows you to stick an Inventor viewer almost anywhere, e.g. in a dialog, just by providing a parent window in the right place. But it also means that the Inventor window gets the mouse events first. There are a number of options including:

  • Use the existing Open Inventor right mouse menu mechanism.
    In the Win32 version of Open Inventor you can replace or extend the right mouse menu without even subclassing the viewer. See the .../src/Inventor/examples/IVF/popup example in the SDK.
  • Use the Open Inventor "raw event" callback.
    The Open Inventor viewers provide a "raw" event callback which allows you to intercept Win32 messages before they are handled by the viewer. You can use this to grab events and stuff them into the normal MFC message map mechanism. See the .../src/Inventor/examples/IVF/Scribble3D example in the SDK.

[Win32] How do I turn off the "auto focus" feature in Open Inventor applications? When the mouse moves over an Inventor window, the window immediately gets the input focus though there is no left-mouse click on it.

Yes, this is an intentional behavior. Without it, you would have to click in the drawing window to restore focus after typing in the zoom edit field in the viewer decorations. Note that the Inventor window will only "steal" focus if the current focus window belongs to the same application window as the Inventor window.

The (undocumented except in the header comments :-) answer is to call SoWinGLWidget::setStealFocus(FALSE). You will then have to click in the Inventor window first before you are in "hand mode" to spin the model in the default viewer scenario. That is, the normal click-to-focus Windows policy will be in effect.

[Win32] In the slotcar demo, how would I specify that I want the window to be frameless? I am going to be running full-screen simulations and I don't want window frames in the scene.

The base window system class (SoXtComponent/SoWinComponent) allows creation of a full screen borderless window. The method used to set/unset full screen mode is: SoWinComponent::setFullScreen. See the help file for details.

[Win32] How can I get a full screen MFC application using Open Inventor?

The base window system class (SoXtComponent/SoWinComponent) allows creation of a full screen borderless window and the Open Inventor viewer's standard right-mouse-button popup menu has been extended to allow the user to switch between normal and full screen mode. See the help file for details.

[Win32] Is there a way to remove the buttons from the viewer decorations, but keep the thumbwheels?

You can suppress just the display of the buttons in the righthand border of the viewer decorations and leave thumbwheels -- this is an undocumented static method:

SoWinFullViewer: :setDoButtonBar( FALSE );

(Because it is a static method, you must have the "SoWinFullViewer::" in front, and you must call the above method before you create the viewer.)

What we recommend when people want to modify the buttons is to suppress the decorations and use a standard MFC toolbar in the application to provide buttons. The utilities behind the buttons and thumbwheels are not public, so you would have to program the functionality of what you wanted your buttons to do.

See the example in the src\Inventor\examples\misc\ViewerButtons folder of the OIV 2.5 distribution for Win32.

[Win32] Can I customize the Open Inventor viewer interface?

What we recommend when people want to modify the buttons is to suppress the decorations and use a standard MFC toolbar in the application to provide buttons. The utilities behind the buttons and thumbwheels are not public, so you would have to program the functionality of what you wanted your buttons to do.

There is an example of how to customize the Open Inventor viewer interface in the Win32 environment. It demonstrates how to:

  • Remove the zoom slider
  • Relabel the thumbwheels
  • Remove buttons from the right-hand side
  • Add custom buttons to the right-hand side

The example is in the src\Inventor\examples\misc\ViewerButtons folder.

[Win32] How can I send a picture of an Inventor scene to a printer?

There are two basic methods to print the graphical display: raster (pixmap) output and vector output. To get raster output, one uses the SoOffscreenRenderer class. The available raster formats are PostScript, JPEG, TIFF, and BMP (BMP is available on Win32 only). See the Mentor example


MFC/IVF applications generated with the IVF AppWizard automatically have support for printing. For example, if you build a default Examiner Viewer application with the IVF AppWizard, you'll find that the File menu has fully functional Print, Print Preview, and Print Setup menu items that use the standard Windows dialogs. Look at examples "PrintA" and "PrintB" under ".../src/Inventor/examples/IVF" to see how this is done (and can be extended or modified).

Vector printing output is accomplished using the HardCopy classes which derive from the abstract base class SoVectorizeAction. The available vector formats are PostScript, HPGL, CGM and GDI (EMF or GDI output is sent directly to the the printer handler for native Windows printing).

[Win32] How should I do rubberbanding?

See also the FAQ question re: using GDI with Open Inventor.

[Win32] How can I modify the Open Inventor cursor(s)? How can I make XOR cursors?

Here are two possibilities:

Using a Custom Cursor
For Open Inventor programs that you write yourself, you can specify the cursor. As of version 2.4, SoWinGLWidget includes methods (setCursor and getCursor) to set and query the current cursor in the Inventor drawing window. This allows Win32 applications to override the standard Open Inventor cursors. See example program in %OIVHOME%\src\Inventor\examples\IVF\popup which changes the popup menu and shows the use of a different cursor.

Using Standard Cursors
The methods SoWinViewer -- setCursorStyle and getCursorStyle -- allow you to set/get "classic" Open Inventor cursors, XOR cursors, or a "shadow" cursor that is visible no matter what color is beneath the cursor. The default cursor is the XOR cursor. You can also use environment variable OIV_CURSOR_STYLE to specify the cursor. See the Open Inventor help file for details.

[Win32] Where does Open Inventor (the help button on the viewer) search for the help file (Inventor.hlp)?

Open Inventor searches, in order, the following locations:

  1. %SO_HELP_DIR%
  2. %OIVHOME%\doc
  3. current working directory
  4. standard Windows directory (getWindowsDirectory)
  5. current path

[Win32] Can I get the Inventor viewer decoration Help button to reference my help file, not the Inventor help file?

Yes! Use these SoWinViewer methods:


If you've used the IVF AppWizard to build your application, these calls go in the OnInitialUpdate method in your C<app>View class. You need to specify the name of the help file and the topic from the help file that you want to display. The topic is identified by its context ID (number).

You may also need to add:

#include < Inventor/Win/viewers/SoWinFullViewer.h>

The help file is searched for in a variety of places:

  • The directory specified by environment variable SO_HELP_DIR
  • The doc directory of the Open Inventor installation (%OIVHOME%\doc)
  • The current working directory
  • The standard Windows directory
  • The current path

When the user clicks on the Help button, the program should display the help file at the topic specified in yourContextID.

[Win32] Why do the distributed Mentor examples use "ivMain"?

OIV 4.0 and older: In 1995 when Open Inventor for Win32 was introduced, there was no such thing as a Windows console application that would allow direct porting of UNIX-style programs, such as the Inventor Mentor example programs. Therefore we had to translate the Mentor programs to real Windows applications, which do not allow the use of a function named "main". To do this we created the INVU library, which contains WinMain (which is Window's own version of the main entry point). Our WinMain turns around and calls ivMain. If you rename "main" to ivMain in your program (which our example programs do with the following code):

#ifdef WIN32
#   define main ivMain

then you have a Windows application that behaves like a console application.

The above kludge is now obsolete with the introduction by Microsoft of true console applications. We have not taken the time, however, to convert the Mentor applications to Microsoft console applications. [Note: As of OIV 3.1, the Mentor examples have been converted to genuine console apps.]

Note that true console apps always open a console window, whereas our faux console applications do not. The print.c/h files found in the Mentor folder are for allowing the use of printf functions.

[Win32] How can I access the Intellisense functionality of Microsoft Visual C++ when writing an Open Inventor application in the IDE?

(Intellisense is the feature that allows Visual Studio to propose through a pulldown menu the different fields, methods, etc. of a class while you're in edit mode).

  1. (Optional) Add oiv/include directories to the list of "source files" in the Tools > Options > Directories menu of Visual Studio.
  2. (Optional) Select the option "Build browse info file" in the target "Browse Info" of the project.
  3. Rebuild the project.
  4. Move the files from External Dependencies to Header Files.

Visual Studio can now show information about Open Inventor classes.