在对话框中嵌入对话框,并在MFC中点击按钮进行切换 [英] Embedding dialogs in main dialog and switching them with button click in MFC
问题描述
我的设计如下:
所以基本上,我想在应用程序主对话框中嵌入三个对话框,并在它们之间切换,对于每个按钮点击,即按钮1将显示对话框一,按钮2将隐藏对话框1并显示对话框2 ..等等。
每个对话框将具有不同的设计和功能。
我尝试使用CPropertySheet类添加页面,但其GUI是不同的。它可以使用下一个/后退按钮或从选项卡控件导航对话框的选项。
这些都不是我的要求。
所以我想知道是否可以在MFC中有这样的设计?如果是的话?我应该使用哪个类/控件。
任何帮助将不胜感激。
对于刚刚使用基于对话框的应用程序,我使用的是SetParent()方法。不知道为什么没有人提到它。似乎工作正常
我正在做如下:
VERIFY(pDlg1.Create(PanelDlg :: IDD,this));
VERIFY(pDlg2.Create(PanelDlg2 :: IDD,this));
VERIFY(pDlg3.Create(PanelDlg2 :: IDD,this));
:: SetParent(pDlg1.GetSafeHwnd(),this-> m_hWnd);
:: SetParent(pDlg2.GetSafeHwnd(),this-> m_hWnd);
:: SetParent(pDlg3.GetSafeHwnd(),this-> m_hWnd);
现在我可以随意显示或隐藏子对话框(按钮点击),如下所示:
pDlg1.ShowWindow(SW_SHOW);
pDlg2.ShowWindow(SW_HIDE);
pDlg3.ShowWindow(SW_HIDE);
I have a design like below:
So basically, I want to embed three dialogs in the application main dialog and switch between them, for each button click i.e., button 1 will show dialog one , button 2 will hide dialog 1 and show dialog 2 .. and so on. Each dialog will be having a different design and functions.
I tried using CPropertySheet class to Add pages but its GUI is different. It has either option for navigating the dialogs using next / back button , or from a tab control. None of which is as per my requirement.
So I want to know is it possible to have a design like this in MFC ? If yes how? Which Class/ control should I use.
Any help will be appreciated.
What worked for me just using dialog based application is SetParent() method. Dont know why nobody mentioned it. It seems to work fine. I am doing like below:
VERIFY(pDlg1.Create(PanelDlg::IDD, this));
VERIFY(pDlg2.Create(PanelDlg2::IDD, this));
VERIFY(pDlg3.Create(PanelDlg2::IDD, this));
::SetParent(pDlg1.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg2.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg3.GetSafeHwnd(), this->m_hWnd);
Now I can show or hide a child dialog at will (button clicks) as below:
pDlg1.ShowWindow(SW_SHOW);
pDlg2.ShowWindow(SW_HIDE);
pDlg3.ShowWindow(SW_HIDE);
这篇关于在对话框中嵌入对话框,并在MFC中点击按钮进行切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!