VC++程序代码.docx
《VC++程序代码.docx》由会员分享,可在线阅读,更多相关《VC++程序代码.docx(16页珍藏版)》请在冰豆网上搜索。
![VC++程序代码.docx](https://file1.bdocx.com/fileroot1/2022-11/30/f2ee23cb-bf31-4262-b48f-503bab814723/f2ee23cb-bf31-4262-b48f-503bab8147231.gif)
VC++程序代码
//ButtonTestDlg.cpp:
implementationfile
//
#include"stdafx.h"
#include"ButtonTest.h"
#include"ButtonTestDlg.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CButtonTestDlgdialog
CButtonTestDlg:
:
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=_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
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCButtonTestDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CButtonTestDlg)
DDX_Control(pDX,IDC_COMBO11,m_age);
DDX_Control(pDX,IDC_COMBO9,m_bloodtype);
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(pDX,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_Text(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,IDC_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_MAP
}
BEGIN_MESSAGE_MAP(CButtonTestDlg,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_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(IDC_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_CLICKED(IDC_CHECK22,OnCheck22)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CButtonTestDlgmessagehandlers
BOOLCButtonTestDlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
CheckRadioButton(IDC_RADIO1,IDC_RADIO4,IDC_RADIO1);
CheckRadioButton(IDC_RADIO5,IDC_RADIO6,IDC_RADIO5);
CheckRadioButton(IDC_RADIO7,IDC_RADIO20,IDC_RADIO7);
CheckRadioButton(IDC_RADIO21,IDC_RADIO27,IDC_RADIO27);
CheckRadioButton(IDC_RADIO28,IDC_RADIO34,IDC_RADIO30);
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCButtonTestDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCButtonTestDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCButtonTestDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCButtonTestDlg:
:
OnCheck1()
{
if(m_A1)
m_A1=false;
elsem_A1=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck2()
{
if(m_A2)
m_A2=false;
elsem_A2=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck3()
{
if(m_A3)
m_A3=false;
elsem_A3=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck4()
{
if(m_A4)
m_A4=false;
elsem_A4=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck20()
{
if(m_A5)
m_A5=false;
elsem_A5=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck21()
{
if(m_A6)
m_A6=false;
elsem_A6=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck5()
{
if(m_B1)
m_B1=false;
elsem_B1=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck6()
{
if(m_B2)
m_B2=false;
elsem_B2=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck7()
{
if(m_B3)
m_B3=false;
elsem_B3=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck8()
{
if(m_B4)
m_B4=false;
elsem_B4=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck9()
{
if(m_B5)
m_B5=false;
elsem_B5=true;
//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck22()
{
if(m_B6)
m_B6=false;
elsem_B6=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck11()
{
if(m_C1)
m_C1=false;
elsem_C1=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck12()
{
if(m_C2)
m_C2=false;
elsem_C2=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck13()
{
if(m_C3)
m_C3=false;
elsem_C3=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck14()
{
if(m_C4)
m_C4=false;
elsem_C4=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck15()
{
if(m_C5)
m_C5=false;
elsem_C5=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck16()
{
if(m_C6)
m_C6=false;
elsem_C6=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck17()
{
if(m_C7)
m_C7=false;
elsem_C7=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck18()
{
if(m_C8)
m_C8=false;
elsem_C8=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnCheck19()
{
if(m_C9)
m_C9=false;
elsem_C9=true;//TODO:
Addyourcontrolnotificationhandlercodehere
}
voidCButtonTestDlg:
:
OnButtonshow()
{