MFC操作父窗口的子控件
//使用SetDlgItemTextCWnd* pDlg=GetParent();if(pDlg){pDlg->SetDlgItemText(IDC_EDITADD,_T("测试edit"));}//使用GetDlgItemCWnd* pDlg=GetParent();if(pDlg){CListBox* pListBox=(CListBox
·
//使用SetDlgItemText
CWnd* pDlg=GetParent();
if(pDlg)
{
pDlg->SetDlgItemText(IDC_EDITADD,_T("测试edit"));
}
//使用GetDlgItem
CWnd* pDlg=GetParent();
if(pDlg)
{
CListBox* pListBox=(CListBox*)pDlg->GetDlgItem(IDC_LISTADD);
if(pListBox)
{
pListBox->InsertString(-1,_T("测试list"));
}
}
//强制转换为自定义窗口类
CMyWindow* pDlg=(CMyWindow*)GetParent();
if(pDlg)
{
//m_listAdd是父窗口类里公开的成员变量
pDlg->m_listAdd.InsertString(-1,_T("测试list"));
}
更多推荐
已为社区贡献1条内容
所有评论(0)