15,979
社区成员
发帖
与我相关
我的任务
分享
BOOL CMy20Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
CTabCtrl* pTab=(CTabCtrl*)GetDlgItem(IDC_TAB1);
pTab->InsertItem(0,"Tab Page1");
pTab->InsertItem(1,"Tab Page2");
pTab->InsertItem(2,"Tab Page3");
pTab->InsertItem(3,"Tab Page4");
prop1.Create(IDD_PROP1,GetDlgItem(IDC_TAB1));
prop2.Create(IDD_PROP2,GetDlgItem(IDC_TAB1));
prop3.Create(IDD_PROP3,GetDlgItem(IDC_TAB1));
prop4.Create(IDD_PROP4,GetDlgItem(IDC_TAB1));
RECT rect;
pTab->GetClientRect(&rect);
rect.top+=30;
rect.left+=5;
rect.right-=5;
rect.bottom-=5;
prop1.MoveWindow(&rect);
prop2.MoveWindow(&rect);
prop3.MoveWindow(&rect);
prop4.MoveWindow(&rect);
prop1.ShowWindow(SW_SHOW);
prop2.ShowWindow(SW_HIDE);
prop3.ShowWindow(SW_HIDE);
prop4.ShowWindow(SW_HIDE);
pTab->SetCurSel(0);
prop1.EnableWindow();
prop2.EnableWindow();
prop3.EnableWindow();
prop4.EnableWindow();
return TRUE; // return TRUE unless you set the focus to a control
}
void CMy20Dlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int n=((CTabCtrl*)GetDlgItem(IDC_TAB1))->GetCurSel();
if (n==0)
{
prop1.ShowWindow(SW_SHOW);
prop2.ShowWindow(SW_HIDE);
prop3.ShowWindow(SW_HIDE);
prop4.ShowWindow(SW_HIDE);
}
else if (n==1)
{
prop1.ShowWindow(SW_HIDE);
prop2.ShowWindow(SW_SHOW);
prop3.ShowWindow(SW_HIDE);
prop4.ShowWindow(SW_HIDE);
}
else if(n==2)
{
prop1.ShowWindow(SW_HIDE);
prop2.ShowWindow(SW_HIDE);
prop3.ShowWindow(SW_SHOW);
prop4.ShowWindow(SW_HIDE);
}
else
{
prop1.ShowWindow(SW_HIDE);
prop2.ShowWindow(SW_HIDE);
prop3.ShowWindow(SW_HIDE);
prop4.ShowWindow(SW_SHOW);
}
*pResult = 0;
}
在下面函数中写代码则出现以上错误,不知应该在哪里添加void CProp1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProp1)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("1");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("3");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("4");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("6");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("6");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("3");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("2");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("4");
((CComboBox*)GetDlgItem(IDC_COMBO2))->AddString("6");
((CComboBox*)GetDlgItem(IDC_COMBO2))->SetCurSel(0);
}
void CProp1::OnButton2()
{
// TODO: Add your control notification handler code here
CString m_strTiangan;
int index2;
CString x,z;
// CString a=+
index2=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index2,m_strTiangan);
x=m_strTiangan;
// MessageBox(x);
z=x;
if (z.Compare("2")==0)
{
SetDlgItemText(IDC_EDIT1,"冬月初二初三初四初五初六初七初八初九初十");
}
}
前面3个选项卡还可以使用但是后面的选项卡就出现问题了。
CProp1 prop1;
CProp2 prop2;
CProp3 prop3;
CProp3 prop4;
void CProp4::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProp4)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("4");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("5");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("6");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("7");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("8");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("5");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("7");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("8");
((CComboBox*)GetDlgItem(IDC_COMBO4))->AddString("2");
((CComboBox*)GetDlgItem(IDC_COMBO4))->SetCurSel(0);
}
前面三处代码都是这样写的没有任何问题,但是只要到第四个就出现问题,已经试过几次都出现这样的问题。