面向对象程序设计课程设计报告《电子时钟》(C++) 联系客服

发布时间 : 星期一 文章面向对象程序设计课程设计报告《电子时钟》(C++)更新完毕开始阅读c17380610b1c59eef8c7b464

END_MESSAGE_MAP() CDateTimeApp::CDateTimeApp() { }

CDateTimeApp theApp;

BOOL CDateTimeApp::InitInstance() {

AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls();

// Call this when using MFC in a shared DLL

#else

Enable3dControlsStatic(); // Call this when linking to MFC statically

#endif 幕中央

8

SetRegistryKey(_T(\

LoadStdProfileSettings(); // Load standard INI file options (including MRU) CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate(

IDR_MAINFRAME,

RUNTIME_CLASS(CDateTimeDoc),

RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CDateTimeView));

AddDocTemplate(pDocTemplate); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (!ProcessShellCommand(cmdInfo)) return FALSE;

m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow();

m_pMainWnd->SetWindowPos(NULL,0,0,400,250,SWP_SHOWWINDOW); AfxGetMainWnd()->CenterWindow(CWnd::GetDesktopWindow());//窗口置屏

}

return TRUE;

class CAboutDlg : public CDialog //对话框类,负责设置时间 { public: };

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { }

void CAboutDlg::DoDataExchange(CDataExchange* pDX) { }

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP()

void CDateTimeApp::OnAppAbout() { }

// DateTimeDoc.h文件,文档类,定义了文字信息的属性

#if !defined(AFX_DATETIMEDOC_H__7CB32F09_D9D2_4ABD_87CA_F51383AFDC67__INCLUDED_)

#define

AFX_DATETIMEDOC_H__7CB32F09_D9D2_4ABD_87CA_F51383AFDC67__INCLU

9

CAboutDlg();

enum { IDD = IDD_ABOUTBOX }; protected:

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support protected:

DECLARE_MESSAGE_MAP()

CDialog::DoDataExchange(pDX);

CAboutDlg aboutDlg; aboutDlg.DoModal();

DED_

#if _MSC_VER > 1000 #pragma once

#endif // _MSC_VER > 1000

class CDateTimeDoc : public CDocument { protected:

CDateTimeDoc();

DECLARE_DYNCREATE(CDateTimeDoc)

public:

int year,month,day,hour,minute,second; //定义int型变量用以计算时间 CString str_year,str_month,str_day,str_hour,str_minute,str_second; //定义

CString型变量用以显示

CString str1,str2,str3; public:

virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar);

public:

virtual ~CDateTimeDoc();

#ifdef _DEBUG

virtual void AssertValid() const;

virtual void Dump(CDumpContext& dc) const;

#endif protected: protected: }; #endif

// DateTimeDoc.cpp 文件 #include \

10

DECLARE_MESSAGE_MAP()

#include \#include \#ifdef _DEBUG

#define new DEBUG_NEW #undef THIS_FILE

static char THIS_FILE[] = __FILE__; #endif

IMPLEMENT_DYNCREATE(CDateTimeDoc, CDocument) BEGIN_MESSAGE_MAP(CDateTimeDoc, CDocument) END_MESSAGE_MAP() CDateTimeDoc::CDateTimeDoc() {

day=1;month=0;year=110;hour=0;minute=0;second=0;

str_year=\

\

}

CDateTimeDoc::~CDateTimeDoc() { }

BOOL CDateTimeDoc::OnNewDocument() { }

void CDateTimeDoc::Serialize(CArchive& ar) {

if (!CDocument::OnNewDocument())

return FALSE;

return TRUE;

if (ar.IsStoring()) {

}

else {

}

11