如何初始化CPropertyPages和CPropertyPages之间的交互 [英] How to initialize CPropertyPages and Interactions between CPropertyPages

查看:61
本文介绍了如何初始化CPropertyPages和CPropertyPages之间的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我目前在尝试使用属性表"和属性页"对Tab控件进行编码时遇到问题.我的工作的第一个版本是一个对话框,现在由于组件众多,我希望将其放在选项卡中.

多亏了这里的教程,我可以将选项卡对话框显示出来而没有任何问题.但是,选项卡(IDD_PROPPAGE_LARGE)似乎没有用于初始化普通对话框的OnInitDialog()方法.在将属性页添加到工作表之前,我试图添加代码,但是它给出了一个错误,
该组件为null.

Hi,

I am currently having problems trying to code Tab control using Property Sheets and Property Pages. My first version of my work is a single dialog box, now due to the many components, I wish to put them in tabs instead.

I am able to get the tab dialog out without any problems thanks to the tutorials here. However it seems like the tabs (IDD_PROPPAGE_LARGE) does not have the OnInitDialog() method which is used to initialize a normal dialog box. I tried to add the code before I add the property page to the sheet but it gives an error that
the component is null.

[code]
// 

// previously:
BOOL CDialogTest1::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	CEdit *pEdit1 = (CEdit*) GetDlgItem(IDC_EDIT1); // unable to get CWnd here
        pBtn1->SetWindowText(CString("XXX"));

	//init flags
	mFlaga = false;
        mFlagb = false;
        mFlagc = false;
	mMsgLen   = 0;

// .........
[/code]



我面临的第二个问题是按下选项卡对话框中的按钮,它将更新另一个选项卡对话框的mfc组件,例如列表控件.



The second problem i am facing is that when a component e.g. a button in a tab dialog is pressed, it will update another tab dialog''s mfc component e.g. list control. is that possible?

推荐答案

^ ].

我面临的第二个问题是按下选项卡对话框中的按钮,它将更新另一个选项卡对话框的mfc组件,例如列表控件.有可能吗?

是的.
Download the property sheet sample from here[^].

The second problem i am facing is that when a component e.g. a button in a tab dialog is pressed, it will update another tab dialog''s mfc component e.g. list control. is that possible?

Yes.


通常,当我处理PropertySheet
时,我使用以下结构
效果很好.

代码示例创建一个属性表样式的对话框,在我的情况下,该对话框在CMainFrame类中处理,但您也可以在View或Document中同样处理它.
Generally, I use the following structure when I deal with PropertySheet

Works well.

Code example creates a property sheet styled dialog, in my case it is handled in CMainFrame class but you could equally handle it in View or Document

void CMainFrame::OnOptions()
{
	CPropertySheet psheet;
	CPropPage1 p1;		// CPropPage1 derived from CPropertyPage
	CPropPage2 p2;		// CPropPage2 derived from CPropertyPage
			
	//
	// Init is a custom method implemented in CPropPage1 and CPropPage2
	// For example, you may want to initialize data in property page objects
	//
	p1.Init();		
	p2.Init();
		
	// set the title
	psheet.SetTitle("My Options",0);

	//add all the pages into the PropertySheet
	psheet.AddPage(&p1);
	psheet.AddPage(&p2);
	
	//
	// The first call to this will cause An exception which is safely handled by OS
	// See Microsoft''s explanation
	// http://support.microsoft.com/kb/q158552/
	//
	// Display the property sheet...
	if (psheet.DoModal() == IDOK)
	{
		//
		// PostProcessing is a custom method implemented in CPropPage1 and CPropPage2
		// For example, you may want to copy data from p1 and p2 to your document
		//
		p1.PostProcessing();
		p2.PostProcessing();
	}
}


这篇关于如何初始化CPropertyPages和CPropertyPages之间的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆