1、VC+程序代码/ ButtonTestDlg.cpp : implementation file/#include stdafx.h#include ButtonTest.h#include ButtonTestDlg.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic: CAboutDlg();/ Dialog Data
2、 /AFX_DATA(CAboutDlg) enum IDD = IDD_ABOUTBOX ; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL/ Implementationprotected: /AFX_MSG(CAboutDlg) /AFX_MSG DECLARE_MESSAGE_MAP()
3、;CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAboutDlg) /AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CAboutDlg) /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog) /AFX_MSG_MAP(CAboutDlg) / No message handlers /AFX_MSG_MA
4、PEND_MESSAGE_MAP()/ CButtonTestDlg dialogCButtonTestDlg:CButtonTestDlg(CWnd* pParent /*=NULL*/) : CDialog(CButtonTestDlg:IDD, pParent) /AFX_DATA_INIT(CButtonTestDlg) m_A1 = FALSE; m_A2 = FALSE; m_A3 = FALSE; m_A4 = FALSE; m_B1 = FALSE; m_B2 = FALSE; m_B3 = FALSE; m_B4 = FALSE; m_B5 = FALSE; m_result
5、 = _T(提示:按“获取信息”键即可获取您的相关信息!); m_name = _T(请输入您的名字); m_hometown = _T(请输入您的籍贯); m_address = _T(请输入您的住址); m_C1 = FALSE; m_C2 = FALSE; m_C3 = FALSE; m_C4 = FALSE; m_C5 = FALSE; m_C6 = FALSE; m_C7 = FALSE; m_C8 = FALSE; m_C9 = FALSE; m_A5 = FALSE; m_A6 = FALSE; m_B6 = FALSE; /AFX_DATA_INIT / Note that L
6、oadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CButtonTestDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CButtonTestDlg) DDX_Control(pDX, IDC_COMBO11, m_age); DDX_Control(pDX, IDC_COMBO9, m_bloodtype);
7、DDX_Control(pDX, IDC_COMBO8, m_nation); DDX_Control(pDX, IDC_COMBO10, m_marriage); DDX_Control(pDX, IDC_COMBO7, m_constellation); DDX_Control(pDX, IDC_COMBO6, m_animalsign); DDX_Control(pDX, IDC_COMBO5, m_date); DDX_Control(pDX, IDC_COMBO4, m_month); DDX_Control(pDX, IDC_COMBO3, m_year); DDX_Check(p
8、DX, IDC_CHECK1, m_A1); DDX_Check(pDX, IDC_CHECK2, m_A2); DDX_Check(pDX, IDC_CHECK3, m_A3); DDX_Check(pDX, IDC_CHECK4, m_A4); DDX_Check(pDX, IDC_CHECK5, m_B1); DDX_Check(pDX, IDC_CHECK6, m_B2); DDX_Check(pDX, IDC_CHECK7, m_B3); DDX_Check(pDX, IDC_CHECK8, m_B4); DDX_Check(pDX, IDC_CHECK9, m_B5); DDX_T
9、ext(pDX, IDC_EDITSHOW, m_result); DDX_Text(pDX, IDC_EDIT1, m_name); DDX_Text(pDX, IDC_EDIT2, m_hometown); DDX_Text(pDX, IDC_EDIT6, m_address); DDX_Check(pDX, IDC_CHECK11, m_C1); DDX_Check(pDX, IDC_CHECK12, m_C2); DDX_Check(pDX, IDC_CHECK13, m_C3); DDX_Check(pDX, IDC_CHECK14, m_C4); DDX_Check(pDX, ID
10、C_CHECK15, m_C5); DDX_Check(pDX, IDC_CHECK16, m_C6); DDX_Check(pDX, IDC_CHECK17, m_C7); DDX_Check(pDX, IDC_CHECK18, m_C8); DDX_Check(pDX, IDC_CHECK19, m_C9); DDX_Check(pDX, IDC_CHECK20, m_A5); DDX_Check(pDX, IDC_CHECK21, m_A6); DDX_Check(pDX, IDC_CHECK22, m_B6); /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CButto
11、nTestDlg, CDialog) /AFX_MSG_MAP(CButtonTestDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_CHECK1, OnCheck1) ON_BN_CLICKED(IDC_CHECK2, OnCheck2) ON_BN_CLICKED(IDC_CHECK3, OnCheck3) ON_BN_CLICKED(IDC_CHECK4, OnCheck4) ON_BN_CLICKED(IDC_CHECK5, OnCheck5) ON_BN_CLICKED(IDC
12、_CHECK6, OnCheck6) ON_BN_CLICKED(IDC_CHECK7, OnCheck7) ON_BN_CLICKED(IDC_CHECK8, OnCheck8) ON_BN_CLICKED(IDC_CHECK9, OnCheck9) ON_BN_CLICKED(IDC_BUTTONSHOW, OnButtonshow) ON_BN_CLICKED(IDC_CHECK11, OnCheck11) ON_BN_CLICKED(IDC_CHECK12, OnCheck12) ON_BN_CLICKED(IDC_CHECK13, OnCheck13) ON_BN_CLICKED(I
13、DC_CHECK14, OnCheck14) ON_BN_CLICKED(IDC_CHECK15, OnCheck15) ON_BN_CLICKED(IDC_CHECK16, OnCheck16) ON_BN_CLICKED(IDC_CHECK17, OnCheck17) ON_BN_CLICKED(IDC_CHECK18, OnCheck18) ON_BN_CLICKED(IDC_CHECK19, OnCheck19) ON_BN_CLICKED(IDC_CHECK20, OnCheck20) ON_BN_CLICKED(IDC_CHECK21, OnCheck21) ON_BN_CLICK
14、ED(IDC_CHECK22, OnCheck22) /AFX_MSG_MAPEND_MESSAGE_MAP()/ CButtonTestDlg message handlersBOOL CButtonTestDlg:OnInitDialog() CDialog:OnInitDialog(); CheckRadioButton(IDC_RADIO1,IDC_RADIO4,IDC_RADIO1); CheckRadioButton(IDC_RADIO5,IDC_RADIO6,IDC_RADIO5); CheckRadioButton(IDC_RADIO7,IDC_RADIO20,IDC_RADI
15、O7); CheckRadioButton(IDC_RADIO21,IDC_RADIO27,IDC_RADIO27); CheckRadioButton(IDC_RADIO28,IDC_RADIO34,IDC_RADIO30); / 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 AppendMenu(MF_SEPARATOR); p
16、SysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); / Set the icon for this dialog. The framework does this automatically / when the applications 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
17、return TRUE; / return TRUE unless you set the focus to a controlvoid CButtonTestDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID & 0xFFF0) = IDM_ABOUTBOX) CAboutDlg dlgAbout; dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you will need the
18、 code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CButtonTestDlg:OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); / Center
19、icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; / Draw the icon dc.DrawIcon(x, y, m_hIcon); else CDialog:OnPaint(); / The
20、system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CButtonTestDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon;void CButtonTestDlg:OnCheck1() if(m_A1) m_A1=false; else m_A1=true; / TODO: Add your control notification handler code here void CButtonTestD
21、lg:OnCheck2() if(m_A2) m_A2=false; else m_A2=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck3() if(m_A3) m_A3=false; else m_A3=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck4() if(m_A4) m_A4=false; else m_A4=true; /
22、 TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck20() if(m_A5) m_A5=false; else m_A5=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck21() if(m_A6) m_A6=false; else m_A6=true; / TODO: Add your control notification handler code
23、here void CButtonTestDlg:OnCheck5() if(m_B1) m_B1=false; else m_B1=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck6() if(m_B2) m_B2=false; else m_B2=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck7() if(m_B3) m_B3=fa
24、lse; else m_B3=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck8() if(m_B4) m_B4=false; else m_B4=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck9() if(m_B5) m_B5=false; else m_B5=true; / TODO: Add your control notifi
25、cation handler code here void CButtonTestDlg:OnCheck22() if(m_B6) m_B6=false; else m_B6=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck11() if(m_C1) m_C1=false; else m_C1=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnChe
26、ck12() if(m_C2) m_C2=false; else m_C2=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck13() if(m_C3) m_C3=false; else m_C3=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck14() if(m_C4) m_C4=false; else m_C4=true; / TODO
27、: Add your control notification handler code here void CButtonTestDlg:OnCheck15() if(m_C5) m_C5=false; else m_C5=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck16() if(m_C6) m_C6=false; else m_C6=true; / TODO: Add your control notification handler code here
28、void CButtonTestDlg:OnCheck17() if(m_C7) m_C7=false; else m_C7=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck18() if(m_C8) m_C8=false; else m_C8=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnCheck19() if(m_C9) m_C9=false; else m_C9=true; / TODO: Add your control notification handler code here void CButtonTestDlg:OnButtonshow()
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1