Use Class Wizard or some other means to create your tab subclassed from CDialog. In the properties for the dialog, change the style of the dialog to “child” and the border to “resizing”. Implement an override for PostNcDestroy(). Replace all occurrences of CDialog with CAdUiTabExtension in all source files for the dialog. In PostNcDestroy() for the tab extension delete the tab object that has been allocated (see example below).
In your AcRx::kInitAppMsg handler in acrxEntryPoint() add a call to acedRegisterExtendedTab("MYAPPNAME.ARX", "DIALOGNAME"), where MYAPPNAME is the base file name of your application and DIALOGNAME is the published name of the extensible tabbed dialog you wish to add to.
Implement an AcRx::kInitDialogMsg handler in acrxEntryPoint() and add the tab there. The (void*)appId argument to acrxEntryPoint() is a CAdUiTabExtensionManager pointer. Use the member function GetDialogName() for the CAdUiTabExtensionManager to get the name of the dialog being initialized and, if the application wants to add to this dialog, call the AddTab() member function of the CAdUiTabExtensionManager to add the tab. If the dialog is resizable and you want some of your controls to resize, add that resizing code after the call to AddTab().
For example:
extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* appId) { switch (msg) { case AcRx::kInitAppMsg: acrxDynamicLinker->unlockApplication(appId); acrxDynamicLinker->registerAppMDIAware(appId); initApp(); break; case AcRx::kUnloadAppMsg: unloadApp(); break; case AcRx::kInitDialogMsg: // A dialog is initializing that we are interested in adding // tabs to. addMyTabs((CAdUiTabExtensionManager*)pkt); break; default: break; } return AcRx::kRetOK; } void initApp() { InitMFC(); // Do other initialization tasks here. acedRegCmds->addCommand( "MYARXAPP", "MYARXAPP", "MYARXAPP", ACRX_CMD_MODAL, &MyArxAppCreate); // Here is where we register the fact that we want to add // a tab to the Options dialog. acedRegisterExtendedTab("MYARXAPP.ARX", "OptionsDialog"); } // CMyTab1 is subclassed from CAcUiTabExtension. static CMyTab1* pTab1; void addMyTabs(CAdUiTabExtensionManager* pXtabManager) { // Allocate an extended tab if it has not been done already // and add it through the CAdUiTabExtensionManager. pTab1 = new CMyTab1; pXtabManager->AddTab(_hdllInstance, IDD_TAB1, "My Tab1", pTab1); // If the main dialog is resizable, add your control // resizing directives here. pTab1->StretchControlXY(IDC_EDIT1, 100, 100); }
Then, for the CMyTab1 class implementation:
void CMyTab1::PostNcDestroy() // Override to delete added tab. { delete pTab1; pTab1 = NULL; CAcUiTabExtension::PostNcDestroy(); }