Building an Class Wizard looking Dialog
-
Hi there! I am trying to build a Dialog-based application which is much like the Visual C Class Wizard. I have played around with a CTabCtrl on the dialog box but I haven't had much luck thus far. Can you give me some hint as to how you would create an application like that? Also, I was wondering whether instead of dumping a CTabCtrl on my dialog, I could attach a CPropertySheet to my CDialog?:confused:
-
Hi there! I am trying to build a Dialog-based application which is much like the Visual C Class Wizard. I have played around with a CTabCtrl on the dialog box but I haven't had much luck thus far. Can you give me some hint as to how you would create an application like that? Also, I was wondering whether instead of dumping a CTabCtrl on my dialog, I could attach a CPropertySheet to my CDialog?:confused:
If it doesn't bother you that the standard buttons of a property sheet are always there use it. If you do - like I do in my dialog-based-application now - you have to use the CTabCtrl. The difference is that you have to create a dialog for each rider of the tab. The tab itself is just a container. So by selecting the riders of a tab you just call up a user-defined dialog.
-
Put a tab (like
IDC_TAB1
) in your dialog (CMyDialog
) with the dialog editor -
Open the Class-Wizard and attach a CTabCtrl-Member-Variable (like
MyTabCtrl
) to your tab-resource (IDC_TAB1
) -
Then you have to tell your tab about the number of riders and their names (with a
TC_ITEM
structure)BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();TC_ITEM TabCtrlItem;
TabCtrlItem.mask = TCIF_TEXT;TabCtrlItem.pszText = "Name of the Rider 1"
MyTabCtrl.InsertItem(0, &TabCtrlItem);TabCtrlItem.pszText = "Name of the Rider 2"
MyTabCtrl.InsertItem(1, &TabCtrlItem);TabCtrlItem.pszText = "Name of the Rider 3"
MyTabCtrl.InsertItem(2, &TabCtrlItem);
} -
Derive a dialog-class (like
CMyFirstRiderDialog
) fromCDialog
-
You should create another dialog resource (like
IDD_MY_FIRST_RIDER
) that represents the content of your rider -
In the function
void CMyDialog::OnShowWindow(BOOL bShow, UINT nStatus)
you'll have to create your rider-dialog.void CMyDialog::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus)if(bShow)
{
MyFirstRiderDialog->Create(IDD_MY_FIRST_RIDER, MyTabCtrl.GetActiveWindow());
MyFirstRiderDialog->ShowWindow(SW_SHOW);
}
} -
In the Message Handler of your
TCN_SELCHANGE
andTCN_SELCHANGING
message of yourIDC_TAB1
object
you have to destroy yourMyFirstRiderDialog
and create the dialog dedicated to your other tabs.void MyDialog::OnSelchangingZone(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(MyTabCtrl.GetCurSelection())
{
case 0:
CMyFirstRiderDialog->DestroyWindow();
break;case 1:
CMySecondRiderDialog->DestroyWindow();
break;default:
ASSERT(0);
break:
}
}void MyDialog::OnSelchangZone(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(MyTabCtrl.GetCurSelection())
{
ca
-