Site Tools


How To: Display MFC Dialogs

C++

Summary: How to display both an MFC modal dialog and an MFC modeless dialog from a Rhino plug-in.

Rhino plug-ins are regular MFC DLLs. Displaying dialog boxes in a Rhino plug-in is not much different than displaying dialog boxes in standalone MFC applications. There can be some issues when accessing resources from within an MFC DLL. For more information, review MFC TechNote 58 entitled “MFC Module State Implementation” in MSDN.

[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html///mfcnotes//tn058.asp]

More Information

MFC's CDialog class supports both modal and modeless dialog. You can use this as a base class for your modal or modeless dialog boxes. The CRhinoDialog class provided by the Rhino SDK adds some enhancements to CDialog, but you are not required to derive your dialog classes from it.

If you are creating your dialog box outside the scope of a plug-in command's RunCommand() member function, make sure to include an AFX_MANAGE_STATE macro to switch the module state. Otherwise you dialog class will not be able to find its dialog resources. For example:

AFX_MANAGE_STATE( AfxGetStaticModuleState() )

Also, if you want to create and display a modeless dialog, please review MSDN article Q103788, entitled “INFO: Creating a Modeless Dialog Box with MFC Libraries”.

Rhino 3 Sample

The attached sample Rhino plug-in demonstrates how to create and display both a modal and a modeless dialog box.

Rhino 3 Sample - http://en.wiki.mcneel.com/content/upload/files/TestDialog.zip

Rhino 4 Sample

The attached sample Rhino plug-in demonstrates how to create and display both a modal and a modeless dialog box.

Rhino 4 Sample - http://en.wiki.mcneel.com/content/upload/files/ModelessSample.zip

developer/plugindialogs.txt · Last modified: 2015/09/14 (external edit)