You can certainly use the CExtPropertyGridCtrl
window as a child control inside your property page window. Just think about your property page window as though it is a simple dialog window. There are two samples in Prof-UIS where the property grid control is used in the dialog window: PropertyGrid and CompoundProperties. There is a IDD_DIALOG_MAIN
dialog template resource in the PropertyGrid sample. The IDC_PROPERTY_GRID_CTRL
custom control is used as the property grid control on this dialog. So, insert the same custom control into your property page’s dialog template resource and specify exactly the same properties of the custom control. The CMainDlg
class in the PropertyGrid sample application corresponds to the IDD_DIALOG_MAIN
dialog template resource. This class is the dialog window, but there is no principal differences between the dialog and the property page. The CMainDlg::m_PGC
property is a CExtPropertyGridCtrl
window. You should insert the same property into your property page class. Finally, add the following line to the DoDataExchange()
virtual method of your property page class as it is done in the CMainDlg::DoDataExchange()
method of the PropertyGrid sample:
DDX_Control( pDX, IDC_PROPERTY_GRID_CTRL, m_PGC );
Now you should see the propery grid control created correctly inside your property page window and you can initialize it in the
OnInitDialog()
method. You should use the following code to hide the combo box bar inside the property grid control:
CExtPropertyGridComboBoxBar * pCombo =
STATIC_DOWNCAST(
CExtPropertyGridComboBoxBar,
m_PGC.GetChildByRTC(
RUNTIME_CLASS(CExtPropertyGridComboBoxBar)
)
);
ASSERT_VALID( pCombo );
pCombo->ShowWindow( SW_HIDE );
m_PGC.RecalcLayout();
It is not necessary to use the collection of property stores and the combo box bar. You can keep one property store and attach it to the property grid control using the following code:
CExtPropertyStore * pPS = . . .
m_PGC.PropertyStoreSet( pPS );