西華大學(xué)C++實(shí)驗(yàn)報(bào)告6對(duì)話框、按鈕及編輯框控件_第1頁
西華大學(xué)C++實(shí)驗(yàn)報(bào)告6對(duì)話框、按鈕及編輯框控件_第2頁
西華大學(xué)C++實(shí)驗(yàn)報(bào)告6對(duì)話框、按鈕及編輯框控件_第3頁
西華大學(xué)C++實(shí)驗(yàn)報(bào)告6對(duì)話框、按鈕及編輯框控件_第4頁
西華大學(xué)C++實(shí)驗(yàn)報(bào)告6對(duì)話框、按鈕及編輯框控件_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、 西華大學(xué)實(shí)驗(yàn)報(bào)告第 組 . 西華大學(xué)實(shí)驗(yàn)報(bào)告(計(jì)算機(jī)類)開課學(xué)院及實(shí)驗(yàn)室:機(jī)械工程與自動(dòng)化 實(shí)驗(yàn)時(shí)間 : 年 月 日學(xué) 生 姓 名 學(xué) 號(hào) 成 績學(xué)生所在學(xué)院機(jī)械工程與自動(dòng)化年級(jí)/專業(yè)/班2011級(jí)機(jī)電 班課 程 名 稱高級(jí)語言在測(cè)控中的應(yīng)用課 程 代 碼6003559實(shí)驗(yàn)項(xiàng)目名稱簡單的MFC應(yīng)用程序設(shè)計(jì)項(xiàng) 目 代 碼指 導(dǎo) 教 師項(xiàng) 目 學(xué) 分一、實(shí)驗(yàn)?zāi)康?. 理解Windows編程特點(diǎn);2. 了解MFC應(yīng)用程序的消息映射、數(shù)據(jù)映射機(jī)制;3. 掌握用AppWizard(exe)創(chuàng)建SDI和MDI應(yīng)用程序的方法;4. 掌握使用項(xiàng)目工作區(qū)窗口的ClassView頁面為類添加成員的方法;5. 掌

2、握用ClassWizard映射消息的方法。6. 掌握對(duì)話框編輯器的使用方法;7. 熟悉對(duì)話框的編程過程及控件的創(chuàng)建和使用方法;8. 掌握靜態(tài)控件、按鈕和編輯框控件的使用方法。二、內(nèi)容與設(shè)計(jì)思想上機(jī)實(shí)踐內(nèi)容:1 設(shè)計(jì)一個(gè)對(duì)話框,用于學(xué)生成績的輸入,要求能輸入學(xué)生姓名、學(xué)號(hào)、性別以及3門課程成績,單擊“求平均”按鈕是計(jì)算3門課程的平均成績并顯示在上面的靜態(tài)文本框中。通過單擊“測(cè)試”菜單下的“成績錄入”子菜單調(diào)用該對(duì)話框,在該對(duì)話框中要用到控件:靜態(tài)文本、編輯框(單行和多行)、單選框、復(fù)選框、組框、按鈕等,其運(yùn)行結(jié)果如下:算法設(shè)計(jì)思想與算法實(shí)現(xiàn)步驟等。三、使用環(huán)境操作系統(tǒng):Windowns XP+環(huán)

3、境:Visual C+ 6.0四、核心代碼及調(diào)試過程/ ScoreInput.cpp : Defines the class behaviors for the application./#include "stdafx.h"#include "ScoreInput.h"#include "MainFrm.h"#include "ScoreInputDoc.h"#include "ScoreInputView.h"#ifdef _DEBUG#define new DEBUG_NEW#undef

4、THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CScoreInputAppBEGIN_MESSAGE_MAP(CScoreInputApp, CWinApp)/AFX_MSG_MAP(CScoreInputApp)ON_COMMAND(ID_APP_ABOUT, OnAppAbout)/ NOTE - the ClassWizard will add and remove mapping macros here./ DO NOT EDIT what you see in these blocks of generated code!/AFX_M

5、SG_MAP/ Standard file based document commandsON_COMMAND(ID_FILE_NEW, CWinApp:OnFileNew)ON_COMMAND(ID_FILE_OPEN, CWinApp:OnFileOpen)/ Standard print setup commandON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp:OnFilePrintSetup)END_MESSAGE_MAP()/ CScoreInputApp constructionCScoreInputApp:CScoreInputApp()/ TOD

6、O: add construction code here,/ Place all significant initialization in InitInstance/ The one and only CScoreInputApp objectCScoreInputApp theApp;/ CScoreInputApp initializationBOOL CScoreInputApp:InitInstance()AfxEnableControlContainer();/ Standard initialization/ If you are not using these feature

7、s and wish to reduce the size/ of your final executable, you should remove from the following/ the specific initialization routines you do not need.#ifdef _AFXDLLEnable3dControls();/ Call this when using MFC in a shared DLL#elseEnable3dControlsStatic();/ Call this when linking to MFC statically#endi

8、f/ Change the registry key under which our settings are stored./ TODO: You should modify this string to be something appropriate/ such as the name of your company or organization.SetRegistryKey(_T("Local AppWizard-Generated Applications");LoadStdProfileSettings(); / Load standard INI file

9、options (including MRU)/ Register the application's document templates. Document templates/ serve as the connection between documents, frame windows and views.CSingleDocTemplate* pDocTemplate;pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME,RUNTIME_CLASS(CScoreInputDoc),RUNTIME_CLASS(CMainFra

10、me), / main SDI frame windowRUNTIME_CLASS(CScoreInputView);AddDocTemplate(pDocTemplate);/ Parse command line for standard shell commands, DDE, file openCCommandLineInfo cmdInfo;ParseCommandLine(cmdInfo);/ Dispatch commands specified on the command lineif (!ProcessShellCommand(cmdInfo)return FALSE;/

11、The one and only window has been initialized, so show and update it.m_pMainWnd->ShowWindow(SW_SHOW);m_pMainWnd->UpdateWindow();return TRUE;/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;CButtonm_

12、Avg;floatm_avg;intm_english;intm_yuwen;intm_math;/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 void OnButton1();/AFX_MSGDEC

13、LARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)m_avg = 0.0f;m_english = 0;m_yuwen = 0;m_math = 0;/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)DDX_Control(pDX, IDC_BUTTON1, m_Avg);DDX_Text

14、(pDX, IDC_EDIT1, m_avg);DDX_Text(pDX, IDC_EDIT4, m_english);DDX_Text(pDX, IDC_EDIT5, m_yuwen);DDX_Text(pDX, IDC_EDIT6, m_math);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)ON_BN_CLICKED(IDC_BUTTON1, OnButton1)/AFX_MSG_MAPEND_MESSAGE_MAP()/ App command to run the dialogvoid CScoreInputApp:OnAppAbout()CAboutDlg aboutDlg;aboutDlg.DoModal();/ CScoreInputApp message handlersvoid CAboutDlg:OnButton1() / TODO: Add your control notification handler code here/int s,a,b,c;/float avg;m_avg = 0.0f;m_english = 0;m_yuwen = 0;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論