我在对话框的组合框里直接相应函数,中英文可以正常切换,程序如下:
void CMy111Dlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
int index;
index=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index,m_langchoice);
if (index==1)
{
SetDlgItemText(IDOK,_T("确定"));
SetDlgItemText(IDCANCEL,_T("取消"));
}
else
{
SetDlgItemText(IDOK,"ok");
SetDlgItemText(IDCANCEL,"cancel");
}
}
但是我在组合框旁边加上确定取消按钮,先选择要转换的语言,再按确定按钮,在onok函数里相应,就没法转换,请教~~
void LangChoiceDlg::OnOK()
{
// TODO: Add extra validation here
int index;
index=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index,m_langchoice);
if (index==1)
{
SetDlgItemText(IDC_BUTTON1,_T("确定"));
// SetDlgItemText(IDCANCEL,_T("取消"));
}
else
{
SetDlgItemText(IDC_BUTTON1,"ok");
// SetDlgItemText(IDCANCEL,"cancel");
}
CDialog::OnOK();
}
void CMy111Dlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
int index;
index=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index,m_langchoice);
if (index==1)
{
SetDlgItemText(IDOK,_T("确定"));
SetDlgItemText(IDCANCEL,_T("取消"));
}
else
{
SetDlgItemText(IDOK,"ok");
SetDlgItemText(IDCANCEL,"cancel");
}
}
但是我在组合框旁边加上确定取消按钮,先选择要转换的语言,再按确定按钮,在onok函数里相应,就没法转换,请教~~
void LangChoiceDlg::OnOK()
{
// TODO: Add extra validation here
int index;
index=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index,m_langchoice);
if (index==1)
{
SetDlgItemText(IDC_BUTTON1,_T("确定"));
// SetDlgItemText(IDCANCEL,_T("取消"));
}
else
{
SetDlgItemText(IDC_BUTTON1,"ok");
// SetDlgItemText(IDCANCEL,"cancel");
}
CDialog::OnOK();
}
用你下面的代码运行成功...建议你把最后一句代码: CDialog::OnOK(); 去掉... 对话框消失了 你看不到结果的
你在LangChoiceDlg::OnOK函数里都CDialog::OnOK()了,请问楼主是怎么看到转换失败还是成功的?!