Creating Dialogs - Part I

July 8 2010

This part shows some sample code how a dialog is loaded and added to the dialog hierarchy. We usually try to keep the hierarchy flat, but sometimes its cleaner to use sub dialogs, so the possibility is there.

definition = g_resourceManager.getResource< UIDialogDefinition >( "yesno.odlg" );
YesNoDialog pYesNoDialog = new YesNoDialog;
pYesNoDialog->createFromDefinition( *pUIElementCreator, definition );
pRootDialog->addChild( pYesNoDialog );
g_resourceManager.releaseResource< UIDialogDefinition >( definition );

(Note: I omitted the asserts to improve readability.) No magic going on here: Load the definition (resource) from a file. Create the dialog object. Tell the dialog to use the definition. Add the dialog to the tree. Cleanup.

That’s all.