一个窗口(Main)上有一个Tab Control控件,同时还有一个Edit Box.请问怎么把Tab Control控件上的值传入Edit Box控件.
其中Tab Control控件包括三个窗口DLG1,DLG2,DLG3在DLG1上添加一个按扭,按扭函数为:
void DLG1::OnButton1()
{
CString s="a";
Main dlg; //Main为主窗口
//dlg.ShowWindow(TRUE);
dlg.m_t = s; //m_t为主窗口上Edit Box控件变量
dlg.UpdateData(false);
}
提示"试图执行系统不支持操作".
如果去掉UpdateData(false)没有反映,但肯定值是传过去了,就是控件刷新问题,请问怎么解决?
其中Tab Control控件包括三个窗口DLG1,DLG2,DLG3在DLG1上添加一个按扭,按扭函数为:
void DLG1::OnButton1()
{
CString s="a";
Main dlg; //Main为主窗口
//dlg.ShowWindow(TRUE);
dlg.m_t = s; //m_t为主窗口上Edit Box控件变量
dlg.UpdateData(false);
}
提示"试图执行系统不支持操作".
如果去掉UpdateData(false)没有反映,但肯定值是传过去了,就是控件刷新问题,请问怎么解决?
pdlg ->SetDlgItemText(IDC_EDIT1,s);
Main dlg; //Main为主窗口
//dlg.ShowWindow(TRUE);
dlg.m_t = s; //m_t为主窗口上Edit Box控件变量
dlg.DoModal();
fishion的方法我试了,还是没有反映!
pdlg ->SetDlgItemText(IDC_EDIT1,s);你的是这样?
Main *pDlg=(Main *)GetParent();
pDlg->m_t="abc";
pDlg->UpDateData(FALSE);
Main *pdlg = (Main *)AfxGetMainWnd();
pdlg ->SetDlgItemText(IDC_EDIT1,s); 我试了还是没有反映,值是传过去了,就是控件没刷新!Main *pDlg=(Main *)GetParent();
pDlg->m_t="abc";
pDlg->UpDateData(FALSE);
也试了,点击后直接退出了!
Main *pdlg = (Main *)AfxGetMainWnd();
pdlg ->SetDlgItemText(IDC_EDIT1,s); //ID对了没
{
CString s="a";
Main *pdlg = (Main*)(GetParent()->GetParent()); //Main为对话框类名
pdlg->m_t = s; //对控件赋值,注意m_t要为CEdit在对话框中管理的CString变量
pdlg->UpdateData(false); //更新窗口
}
但是确实没有反映,是不是别的地方出错了,Tab Control控件会吗,需要有什么属性设置吗?
我的Tab Control控件初始化代码:
void Main::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
int CurSel = m_tab.GetCurSel(); //m_tab是Tab Control控件变量!
switch(CurSel)
{
case 0:
dlgs.ShowWindow(TRUE);
dlgd1.ShowWindow(FALSE);
dlgd2.ShowWindow(FALSE);
break;
case 1:
dlgs.ShowWindow(FALSE);
dlgd2.ShowWindow(FALSE);
dlgd1.ShowWindow(TRUE);
break;
case 2:
dlgs.ShowWindow(FALSE);
dlgd1.ShowWindow(FALSE);
dlgd2.ShowWindow(TRUE);
break;
default:
break;
}
*pResult = 0;
}
pdlg ->GetDlgItem(IDC_EDIT)->SetWindowText("OK");
或
Main *pDlg=(Main *)GetParent();
pDlg ->GetDlgItem(IDC_EDIT)->SetWindowText("OK");这个退出??想想
Main *pDlg=(Main *)GetParent();
pDlg->m_t="abc";
pDlg->UpDateData(FALSE);
"(GetParent()->GetParent())" 都可以是吗??