【VC++开源代码栏目提醒】:网学会员--在 VC++开源代码编辑为广大网友搜集整理了:VC6++《可视化编程》钟表程序实验报告 - 毕业设计绩等信息,祝愿广大网友取得需要的信息,参考学习。
程序设计课程设计 年级 班 学号姓名 1 《可视化编程》课 程 设 计 题目: 1. 编写钟表程序 程序设计课程设计 年级 班 学号姓名 2 题目1编写钟表 问题描述 用
vc6.0编写钟表。
基本要求 1 功能要求编写一个钟表程序能显示出钟表的各种基本功能。
. 实验
代码 // Clock111Dlg.cpp : implementation file // include stdafx.h include Clock111.h include Clock111Dlg.h ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE __FILE__ endif ///////////////////////////////////////////////////////////////////////////// 程序设计课程设计 年级 班 学号姓名 3 // CAboutDlg dialog used for App About class CAboutDlg : public CDialog public: CAboutDlg // Dialog Data //AFX_DATACAboutDlg enum IDD IDD_ABOUTBOX //AFX_DATA // ClassWizard generated virtual function overrides //AFX_VIRTUALCAboutDlg protected: virtual void DoDataExchangeCDataExchange pDX // DDX/DDV support //AFX_VIRTUAL // Implementation protected: //AFX_MSGCAboutDlg 程序设计课程设计 年级 班 学号姓名 4 //AFX_MSG DECLARE_MESSAGE_MAP CAboutDlg::CAboutDlg : CDialogCAboutDlg::IDD //AFX_DATA_INITCAboutDlg //AFX_DATA_INIT void CAboutDlg::DoDataExchangeCDataExchange pDX CDialog::DoDataExchangepDX //AFX_DATA_MAPCAboutDlg //AFX_DATA_MAP BEGIN_MESSAGE_MAPCAboutDlg CDialog //AFX_MSG_MAPCAboutDlg // No message handlers //AFX_MSG_MAP END_MESSAGE_MAP 程序设计课程设计 年级 班 学号姓名 5 ///////////////////////////////////////////////////////////////////////////// // CClock111Dlg dialog CClock111Dlg::CClock111DlgCWnd pParent /NULL/ : CDialogCClock111Dlg::IDD pParent //AFX_DATA_INITCClock111Dlg m_day _T m_month _T m_year _T // NOTE: the ClassWizard will add member initialization here //AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon AfxGetApp-LoadIconIDR_MAINFRAME void CClock111Dlg::DoDataExchangeCDataExchange pDX CDialog::DoDataExchangepDX //AFX_DATA_MAPCClock111Dlg 程序设计课程设计 年级 班 学号姓名 6 DDX_TextpDX IDC_DAY m_day DDX_TextpDX IDC_MONTH m_month DDX_TextpDX IDC_YEAR m_year // NOTE: the ClassWizard will add DDX and DDV calls here //AFX_DATA_MAP BEGIN_MESSAGE_MAPCClock111Dlg CDialog //AFX_MSG_MAPCClock111Dlg ON_WM_SYSCOMMAND ON_WM_PAINT ON_WM_QUERYDRAGICON ON_EN_CHANGEIDC_YEAR OnChangeYear ON_EN_CHANGEIDC_MONTH OnChangeMonth ON_EN_CHANGEIDC_DAY OnChangeDay ON_WM_TIMER //AFX_MSG_MAP END_MESSAGE_MAP ///////////////////////////////////////////////////////////////////////////// // CClock111Dlg message handlers 程序设计课程设计 年级 班 学号姓名 7 BOOL CClock111Dlg::OnInitDialog CDialog::OnInitDialog // Add About... menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERTIDM_ABOUTBOX 0xFFF0 IDM_ABOUTBOX ASSERTIDM_ABOUTBOX 0xF000 CMenu pSysMenu GetSystemMenuFALSE if pSysMenu NULL CString strAboutMenu strAboutMenu.LoadStringIDS_ABOUTBOX if strAboutMenu.IsEmpty pSysMenu-AppendMenuMF_SEPARATOR pSysMenu-AppendMenuMF_STRING IDM_ABOUTBOX strAboutMenu 程序设计课程设计 年级 班 学号姓名 8 // Set the icon for this dialog. The framework does this automatically // when the applications main window is not a dialog SetIconm_hIcon TRUE // Set big icon SetIconm_hIcon FALSE // Set small icon // TODO: Add extra initialization here // // SetTimer1900NULL//这个函数设置一个系统定时器。
指定了一个定时值每当发生超时则系统就向设置定时器的应用程序的消息队列发送一个WM_TIMER消息或者将消息传递给应用程序定义的TimerProc回调函数。
return TRUE // return TRUE unless you set the focus to a control void CClock111Dlg::OnSysCommandUINT nID LPARAM lParam 程序设计课程设计 年级 班 学号姓名 9 if nID 0xFFF0 IDM_ABOUTBOX CAboutDlg dlgAbout dlgAbout.DoModal else CDialog::OnSysCommandnID lParam // If you add a minimize button to your dialog you will need the code below // to draw the icon. For MFC applications using the document/view model // this is automatically done for you by the framework. void CClock111Dlg::OnPaint if IsIconic 程序设计课程设计 年级 班 学号姓名 10 CPaintDC dcthis // device context for painting SendMessageWM_ICONERASEBKGND WPARAM dc.GetSafeHdc 0 // Center icon in client rectangle int cxIcon GetSystemMetricsSM_CXICON int cyIcon GetSystemMetricsSM_CYICON CRect rect GetClientRectrect int x rect.Width - cxIcon 1 / 2 int y rect.Height - cyIcon 1 / 2 // Draw the icon dc.DrawIconx y m_hIcon else CDialog::OnPaint 程序设计课程设计 年级 班 学号姓名 11 // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CClock111Dlg::OnQueryDragIcon return HCURSOR m_hIcon void CClock111Dlg::OnChangeYear // TODO: If this is a RICHEDIT control the control will not // send this notification unless you override the CDialog::OnInitDialog // function and call CRichEditCtrl.SetEventask. // with the ENM_CHANGE flag ORed into the m // TODO: Add your control notification handler code here SYSTEMTIME sys GetLocalTime sys m_year.Formatd 年 sys.wYear UpdateDatafalse 程序设计课程设计 年级 班 学号姓名 12 void CClock111Dlg::OnChangeMonth // TODO: If this is a RICHEDIT control the control will not // send this notification unless you override the CDialog::OnInitDialog // function and call CRichEditCtrl.SetEventMask // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here SYSTEMTIME sys GetLocalTime sys m_month.Formatd 月 sys.wMonth UpdateDatafalse void CClock111Dlg::OnChangeDay // TODO: If this is a RICHEDIT control the control will not // send this notification unless you override the CDialog::OnInitDialog // function and call CRichEditCtrl.SetEventMask 程序设计课程设计 年级 班 学号姓名 13 // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here SYSTEMTIME sys GetLocalTime sys m_day.Formatd 日 sys.wDay UpdateDatafalse include include void CClock111Dlg::OnTimerUINT nIDEvent // TODO: Add your message handler code here and/or call default RedrawWindow CTime time time CTime::GetCurrentTime CDC pDC GetDC 程序设计课程设计 年级 班 学号姓名 14 CPen oldpen pen1pen2pen3pen4pen5pen6 CPen pen11pen22pen33 pen1.CreatePenPS_SOLID2RGB20000 pen4.CreatePenPS_SOLID2RGB20000 pen11.CreatePenPS_SOLID2RGB20000 pen2.CreatePenPS_SOLID4RGB100100200 pen22.CreatePenPS_SOLID2RGB100100200 pen5.CreatePenPS_SOLID5RGB100100200 pen3.CreatePenPS_SOLID6RGB000 pen33.CreatePenPS_SOLID3RGB000 pen6.CreatePenPS_SOLID8RGB000 double pi 3.141592653 double Rad double r double x double y int ox 170 //改变指针圆心位置 程序设计课程设计 年级 班 学号姓名 15 int oy 178 //改变指针圆心位置 int m OnChangeYear //--------------year OnChangeMonth //--------------month OnChangeDay //--------------day //second oldpen pDC-SelectObjectpen1 r 83 m time.GetSecond Rad pi m / 30.0 x sinRad r ox y -cosRad r oy pDC-MoveTooxoy pDC-LineTointxinty int r11 11 int x1 int x - sin Rad 1.0/5.0 r11 int y1 int y cos Rad 1.0/5.0 r11 oldpen pDC-SelectObjectpen1 程序设计课程设计 年级 班 学号姓名 16 pDC-MoveToxy //指针的箭头设定 pDC-LineTointx1inty1 //指针的箭头设定 x1 int x - sin Rad - 1.0/5.0 r11 y1 int y cos Rad - 1.0/5.0 r11 pDC-MoveToxy//指针的箭头设定 pDC-LineTointx1inty1//指针的箭头设定 oldpen pDC-SelectObjectpen4 // about tail r 35 x sinRadpi r ox y -cosRadpi r oy pDC-MoveTooxoy // pDC-LineTointxinty //minute oldpen pDC-SelectObjectpen2 r 71 m time.GetMinute Rad pi m / 30.0 x sinRad r ox y -cosRad r oy 程序设计课程设计 年级 班 学号姓名 17 pDC-MoveToox oy pDC-LineTointxinty r11 8 x1 x - sin Rad 2.0/5.0 r11 y1 y cos Rad 2.0/5.0 r11 oldpen pDC-SelectObjectpen22 pDC-MoveToxy pDC-LineTointx1inty1 x1 x - sin Rad - 2.0/5.0 r11 y1 y cos Rad - 2.0/5.0 r11 pDC-MoveToxy pDC-LineTointx1inty1 oldpen pDC-SelectObjectpen5/////////////// about tail r 20 x sinRadpi r ox y -cosRadpi r oy pDC-MoveToox oy pDC-LineTointxinty 程序设计课程设计 年级 班 学号姓名 18 //hour oldpen pDC-SelectObjectpen3 r 60 m time.GetHour Rad pi m / 6.0 x sinRad r ox y -cosRad r oy pDC-MoveToox oy pDC-LineTointxinty r11 12 x1 x - sin Rad 3.0/7.0 r11 y1 y cos Rad 3.0/7.0 r11 oldpen pDC-SelectObjectpen33 pDC-MoveToxy pDC-LineTointx1inty1 x1 x - sin Rad - 3.0/7.0 r11 y1 y cos Rad - 3.0/7.0 r11 pDC-MoveToxy pDC-LineTointx1inty1 oldpen pDC-SelectObjectpen6/////////////// about tail 程序设计课程设计 年级 班 学号姓名 19 r 12 x sinRadpi r ox y -cosRadpi r oy pDC-MoveToox oy pDC-LineTointxinty CDialog::OnTimernIDEvent 实验结果 课程设计小结 完成实验的心得与体会通过本次的实验更加了解了完成一个完整的程序需要哪些方面的知识学会了编写一个钟表所用到的知识虽然中间也遇到了很多困难但通过询问与虚心的学习还是学到了不少知识最终也完成了实验。
受益匪浅
上一篇:
小型自选商场综合管理系统(ER图+VC++SqlServer+源代码)
下一篇:
按摩连锁财务管理系统|按摩连锁财务管理系统第一版