《可视化编程技术(1).ppt》由会员分享,可在线阅读,更多相关《可视化编程技术(1).ppt(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、控件设计(三)设计(三)n n一、利用一、利用一、利用一、利用AppWizardAppWizard设计对话框应用程序设计对话框应用程序设计对话框应用程序设计对话框应用程序 (用户调查表)用户调查表)n n二、界面设计二、界面设计1 1)删除静态文本)删除静态文本 移动移动 确定确定 和和 取消取消 按钮;按钮;2 2)添加控件)添加控件 按钮按钮 *2 2 静态控件静态控件*7 7 编辑框编辑框*3 3 组合框组合框*2 2 组框组框 *2 2 单选按钮单选按钮*2 2 复选框复选框*6 6n n注意:2个单选按钮要连续添加、6个复选框要连续添加。n n设置控件属性并排列。n n其中 IDC_
2、EDIT_EDIT (所要说的话)n nIDC_RADIO1 Group 打钩n nIDC_STATIC_DISPn nSunken Client edgen n添加成员变量:DDX_Control(pDXDDX_Control(pDX,IDC_STATIC_DISP,IDC_STATIC_DISP,m_Displaym_Display););DDX_Control(pDXDDX_Control(pDX,IDC_COMBO2,IDC_COMBO2,m_Citym_City););DDX_Control(pDXDDX_Control(pDX,IDC_COMBO1,IDC_COMBO1,m_Pro
3、vincem_Province););DDX_Text(pDXDDX_Text(pDX,IDC_EDIT_EDIT,IDC_EDIT_EDIT,m_Editm_Edit););DDX_Text(pDXDDX_Text(pDX,IDC_EDIT_EMAIL,IDC_EDIT_EMAIL,m_Emailm_Email););DDX_Text(pDXDDX_Text(pDX,IDC_EDIT_NAME,IDC_EDIT_NAME,m_Namem_Name););DDX_Radio(pDXDDX_Radio(pDX,IDC_RADIO1,IDC_RADIO1,m_Malem_Male););n n建立
4、消息映射建立消息映射ON_CBN_DROPDOWN(IDC_COMBO2,OnDropdownCombo2)ON_CBN_DROPDOWN(IDC_COMBO2,OnDropdownCombo2)n n添加代码添加代码BOOL BOOL CDCBDlg:OnInitDialogCDCBDlg:OnInitDialog()()/TODO:Add extra initialization here/TODO:Add extra initialization herem_Display.ShowWindow(FALSEm_Display.ShowWindow(FALSE););m_Province.
5、AddStringm_Province.AddString(湖南湖南););m_Province.AddStringm_Province.AddString(河南河南););m_Province.SetCurSel(0);m_Province.SetCurSel(0);m_City.AddStringm_City.AddString(郑州郑州););m_City.AddStringm_City.AddString(洛阳洛阳););m_City.SetCurSel(0);m_City.SetCurSel(0);void CDCBDlg:OnDropdownCombo2()CStringCStri
6、ng m_1;m_1;m_Province.GetWindowText(m_1);m_Province.GetWindowText(m_1);if(m_1=if(m_1=河南河南)m_City.ResetContentm_City.ResetContent();();m_City.AddStringm_City.AddString(郑州郑州););m_City.AddStringm_City.AddString(洛阳洛阳););if(m_1=if(m_1=湖南湖南)m_City.ResetContentm_City.ResetContent();();m_City.AddStringm_Cit
7、y.AddString(长沙长沙););m_City.AddStringm_City.AddString(岳阳岳阳););n n重载重载UpdateData(TRUEUpdateData(TRUE););CStringCString m_1,m_2,m_3,str;m_1,m_2,m_3,str;intint m,im,i;strstr=;=;for(ifor(i=IDC_CHECK1;iIDC_CHECK6+1;i+)=IDC_CHECK1;i)-GetCheckGetCheck();();if(1=m)if(1=m)CStringCString chcktextchcktext;CWnd:
8、GetDlgItemText(i,chcktextCWnd:GetDlgItemText(i,chcktext););chcktextchcktext+=;+=;strstr+=+=chcktextchcktext;if(0=if(0=m_Malem_Male)m_3=m_3=男男;elseelsem_3=m_3=女女;m_Province.GetWindowText(m_1);m_Province.GetWindowText(m_1);m_City.GetWindowText(m_2);m_City.GetWindowText(m_2);SetDlgItemText(IDC_STATIC_N
9、AMESetDlgItemText(IDC_STATIC_NAME,);,);SetDlgItemText(IDC_STATIC_EMAILSetDlgItemText(IDC_STATIC_EMAIL,);,);SetDlgItemText(IDC_STATIC_EDITSetDlgItemText(IDC_STATIC_EDIT,);,);SetDlgItemText(IDC_STATIC_SEXSetDlgItemText(IDC_STATIC_SEX,);,);SetDlgItemText(IDC_STATIC_HOBBYSetDlgItemText(IDC_STATIC_HOBBY,
10、);,);SetDlgItemText(IDC_STATIC_PROVINCESetDlgItemText(IDC_STATIC_PROVINCE,);,);SetDlgItemText(IDC_STATIC_CITYSetDlgItemText(IDC_STATIC_CITY,);,);m_Display.SetWindowText(m_Name+“,”+m_3+“,”+m_1+m_2m_Display.SetWindowText(m_Name+“,”+m_3+“,”+m_1+m_2 +人也。人也。nn您的兴趣有:您的兴趣有:+str+nstr+n+您的地址:您的地址:+m_Email+nm
11、_Email+n+您要说的话:您要说的话:+m_Editm_Edit););m_Display.ShowWindow(TRUEm_Display.ShowWindow(TRUE););m_City.ShowWindow(FALSEm_City.ShowWindow(FALSE););m_Province.ShowWindow(FALSEm_Province.ShowWindow(FALSE););(CEditCEdit*)*)GetDlgItem(IDC_EDIT_NAMEGetDlgItem(IDC_EDIT_NAME)-)-ShowWindow(FALSEShowWindow(FALSE)
12、;);(CEditCEdit*)*)GetDlgItem(IDC_EDIT_EMAILGetDlgItem(IDC_EDIT_EMAIL)-)-ShowWindow(FALSEShowWindow(FALSE););(CEditCEdit*)*)GetDlgItem(IDC_EDIT_EDITGetDlgItem(IDC_EDIT_EDIT)-)-ShowWindow(FALSEShowWindow(FALSE););GetDlgItem(IDC_STATIC1)-GetDlgItem(IDC_STATIC1)-ShowWindow(FALSEShowWindow(FALSE););GetDl
13、gItem(IDC_STATIC2)-GetDlgItem(IDC_STATIC2)-ShowWindow(FALSEShowWindow(FALSE););(CButtonCButton*)GetDlgItem(IDC_RADIO1)-*)GetDlgItem(IDC_RADIO1)-ShowWindow(FALSEShowWindow(FALSE););(CButtonCButton*)GetDlgItem(IDC_RADIO2)-*)GetDlgItem(IDC_RADIO2)-ShowWindow(FALSEShowWindow(FALSE););for(ifor(i=IDC_CHECK1;iIDC_CHECK6+1;i+)=IDC_CHECK1;i)-ShowWindow(FALSEShowWindow(FALSE););(CButtonCButton*)*)GetDlgItem(IDOKGetDlgItem(IDOK)-)-ShowWindow(FALSEShowWindow(FALSE););SetDlgItemText(IDCANCELSetDlgItemText(IDCANCEL,退出退出););
限制150内