




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、/ aaDlg.cpp : implementation file/#include "stdafx.h"#include "aa.h"#include "aaDlg.h"#include "math.h"#include "time.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifstruct saveUINT DrawType;int rectleft;int r
2、ectright;int recttop;int rectbottom;CPoint Origin;CPoint End;SavedGraph 10;static int width=0;static int height=0;/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard generated virtual
3、 function overrides/AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAbou
4、tDlg: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_MAPEND_MESSAGE_MAP()/ CAaDlg dialogCAaDlg:CAaDlg(CWnd* pParent /*=NULL*/): CDialog(CAaDlg:IDD, pParent)/AF
5、X_DATA_INIT(CAaDlg)/ NOTE: the ClassWizard will add member initialization here/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);void CAaDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP
6、(CAaDlg)/ NOTE: the ClassWizard will add DDX and DDV calls here/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAaDlg, CDialog)/AFX_MSG_MAP(CAaDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1, OnButton1)ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)ON_WM_TIMER()ON_BN_CLICKED(IDC_BUTTON3, OnS
7、ettingTime)ON_BN_CLICKED(IDC_BUTTON4, OnAdjustTime)ON_EN_CHANGE(IDC_EDIT3, OnChangeMinute)ON_EN_CHANGE(IDC_EDIT4, OnChangeSecond)ON_BN_CLICKED(IDC_BUTTON2, OnPause_Play)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CAaDlg message handlersBOOL CAaDlg:OnInitDialog()CDialog:OnInitDialog();/ Add "About." men
8、u item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL)CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty
9、()pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the application's main window is not a dialogSetIcon(m_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small
10、 icon/ TODO: Add extra initialization hereModifyStyle( NULL, WS_THICKFRAME);return TRUE; / return TRUE unless you set the focus to a controlvoid CAaDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam
11、);/ 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 CAaDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM
12、_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint 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 icondc.Draw
13、Icon(x, y, m_hIcon);else/用外框進(jìn)行試驗(yàn)/計(jì)算長寬的變化比例/ CRect Rect;/ float x,y;/ x=Rect.right/width;/ / / / SavedGraph0.rectleft*=1;/ SavedGraph0.recttop*=1;/ SavedGraph0.rectright*=1;/ SavedGraph0.rectbottom*=1;/ / /畫方框/ CWnd *pWnd=this;/GetDlgItem(IDC_WORK);/圖畫區(qū)域/ pWnd->GetClientRect(&Rect);/ int nWidt
14、h=Rect.right;/圖畫區(qū)域?qū)挾? int nHeight=Rect.bottom;/圖畫區(qū)域高度/ / /設(shè)置填充色/ CClientDC dc(pWnd);/ CBrush brush;/ brush.CreateSolidBrush(RGB(255,255,255);/填充色/ HBRUSH hNewBrush=(HBRUSH)brush.m_hObject;/ HBRUSH hOldBrush=(HBRUSH)dc.SelectObject(hNewBrush);/ /以下畫方框/ /設(shè)置方框畫筆色 藍(lán)色/ CPen BluePen;/ BluePen.CreatePen( P
15、S_SOLID,5/*線寬*/, RGB(0, 0, 255)/*畫筆色*/);/ CPen * pOldPen1=dc.SelectObject(&BluePen);/ /開始畫方框/ Rect.left=SavedGraph0.rectleft;/ Rect.top=SavedGraph0.recttop;/ Rect.right=SavedGraph0.rectright;/ Rect.bottom=SavedGraph0.rectbottom;/ dc.Rectangle(Rect);/ /恢復(fù)環(huán)境/ dc.SelectObject(hOldBrush);/ dc.Select
16、Object(pOldPen1); / /畫方框結(jié)束CDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CAaDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;static int m_second=-96;static int m_minute=-90;static double m_hour=-90;static double mm_hour=-90;s
17、tatic int i=1;static int num1=0,num2=0,num3=0;static int flag=0;static int flag1=0;static int count=0;void CAaDlg:OnButton1() /第一個(gè)按鈕 畫鐘/ TODO: Add your control notification handler code hereif(count%2=0|count=0)CWnd *pWnd=this;/GetDlgItem(IDC_WORK);/圖畫區(qū)域CRect Rect;pWnd->GetClientRect(&Rect);i
18、nt nWidth=Rect.right;/圖畫區(qū)域?qū)挾萯nt nHeight=Rect.bottom;/圖畫區(qū)域高度width=nWidth;height=nHeight;/設(shè)置填充色CClientDC dc(pWnd);CBrush brush;brush.CreateSolidBrush(RGB(255,255,255);/填充色HBRUSH hNewBrush=(HBRUSH)brush.m_hObject;HBRUSH hOldBrush=(HBRUSH)dc.SelectObject(hNewBrush);/以下畫方框/設(shè)置方框畫筆色 藍(lán)色CPen BluePen;BluePen.
19、CreatePen( PS_SOLID,5/*線寬*/, RGB(0, 0, 255)/*畫筆色*/);CPen * pOldPen1=dc.SelectObject(&BluePen);/開始畫方框Rect.left=90;Rect.top=10;Rect.right=290;Rect.bottom=210;dc.Rectangle(Rect);/保存方框到結(jié)構(gòu)體中/*SavedGraph0.DrawType="Rectangle"*/SavedGraph0.rectleft=Rect.left;SavedGraph0.recttop=Rect.top;Saved
20、Graph0.rectright=Rect.right;SavedGraph0.rectbottom=Rect.bottom;/恢復(fù)環(huán)境dc.SelectObject(hOldBrush);dc.SelectObject(pOldPen1); /設(shè)置黑色畫筆色CPen *BlackPen1 = new CPen( PS_SOLID,1/*線寬*/, RGB(0, 0, 0)/*畫筆色*/);CPen *pOldPen=dc.SelectObject(BlackPen1);/以下畫圓HBRUSH hOldBrush1 = (HBRUSH)dc.SelectObject(hNewBrush);Re
21、ct.left=100;Rect.top=20;Rect.right=280;Rect.bottom=200;/圓區(qū)域dc.Ellipse(Rect);/畫圓dc.SelectObject(hOldBrush1);/恢復(fù)環(huán)境dc.SelectObject(hOldBrush1);dc.SelectObject(pOldPen); delete BlackPen1;/畫中間的圓CBrush brush1;brush1.CreateSolidBrush(RGB(250,0,0);HBRUSH hNewBrush11=(HBRUSH)brush1.m_hObject;HBRUSH hOldBrush
22、11=(HBRUSH)dc.SelectObject(hNewBrush11);/HBRUSH hOldBrush11 = (HBRUSH)dc.SelectObject(hNewBrush11);Rect.left=185;Rect.top=105;Rect.right=195;Rect.bottom=115;/圓區(qū)域CPen *RedPen=new CPen(PS_SOLID,1/*線寬*/, RGB(250, 0, 0)/*畫筆色*/);CPen *pOldPen4=dc.SelectObject(RedPen);dc.Ellipse(Rect);/畫圓/恢復(fù)環(huán)境dc.SelectObj
23、ect(hOldBrush11);dc.SelectObject(pOldPen4); delete RedPen;/以下開始畫刻度線,先畫4條在x軸和y軸的/先對(duì)4條xy軸的刻度線設(shè)置顏色CPen BlackPen2;BlackPen2.CreatePen(PS_SOLID,4,RGB(0,0,0);CPen *pOldPen2=dc.SelectObject(&BlackPen2);/開始畫刻度CPoint point1=dc.MoveTo(190,20); /起點(diǎn)1dc.LineTo(190,35);/終點(diǎn)1CPoint point2=dc.MoveTo(190,200); /起
24、點(diǎn)2dc.LineTo(190,185);/終點(diǎn)2CPoint point3=dc.MoveTo(280,110); /起點(diǎn)3dc.LineTo(265,110);/終點(diǎn)3CPoint point4=dc.MoveTo(100,110); /起點(diǎn)4dc.LineTo(115,110);/終點(diǎn)4/恢復(fù)環(huán)境dc.SelectObject(pOldPen2); /寫刻度上的字CFont font;LOGFONT lf;memset(&lf, 0, sizeof(LOGFONT);lf.lfHeight = 15; /字高strcpy(lf.lfFaceName, "Times Ne
25、w Roman"); /字體VERIFY(font.CreateFontIndirect(&lf);HGDIOBJ oldfont=dc.SelectObject(font.m_hObject);dc.SetTextColor(RGB(0,0,0);/設(shè)置文字顏色dc.SetBkMode(TRANSPARENT);/文字背景透明dc.TextOut(185,37,"12");dc.TextOut(187,168,"6");dc.TextOut(120,103,"9");dc.TextOut(252,103,"
26、;3");dc.SelectObject(oldfont);/畫剩余的刻度,綠色的刻度/設(shè)置畫筆的顏色CPen GreenPen;GreenPen.CreatePen(PS_SOLID,4,RGB(0,128,0);CPen *pOldPen3=dc.SelectObject(&GreenPen);/開始畫剩余的刻度int mm,nn;mm=int(90.0*sqrt(3.0)/2);nn=int(70.0*sqrt(3.0)/2);CPoint point5=dc.MoveTo(190+45,110-mm); /起點(diǎn)5dc.LineTo(190+35,110-nn);/終點(diǎn)
27、5CPoint point6=dc.MoveTo(190+mm,110-45); /起點(diǎn)6dc.LineTo(190+nn,110-35);/終點(diǎn)6CPoint point7=dc.MoveTo(190+mm,110+45); /起點(diǎn)7dc.LineTo(190+nn,110+35);/終點(diǎn)7CPoint point8=dc.MoveTo(190+45,110+mm); /起點(diǎn)8dc.LineTo(190+35,110+nn);/終點(diǎn)8CPoint point9=dc.MoveTo(190-45,110-mm); /起點(diǎn)9dc.LineTo(190-35,110-nn);/終點(diǎn)9CPoint
28、point10=dc.MoveTo(190-mm,110-45); /起點(diǎn)10dc.LineTo(190-nn,110-35);/終點(diǎn)10CPoint point11=dc.MoveTo(190-mm,110+45); /起點(diǎn)11dc.LineTo(190-nn,110+35);/終點(diǎn)11CPoint point12=dc.MoveTo(190-45,110+mm); /起點(diǎn)12dc.LineTo(190-35,110+nn);/終點(diǎn)12/恢復(fù)環(huán)境dc.SelectObject(pOldPen3); /輸出當(dāng)前時(shí)間if(flag=0)PutOutCurrentTime();SetTimer(1
29、,1000,0);/設(shè)定1秒鐘時(shí)間/畫秒針int x,y;double pi=3.1415926;m_second+=6;x=int(190+60*cos(m_second*pi/180);y=int(110+60*sin(m_second*pi/180);if(m_second=360) m_second=0;CPen *OrangePen1=new CPen(PS_SOLID,1/*線寬*/, RGB(250, 200, 0)/*畫筆色*/);CPen *pOldPen5=dc.SelectObject(OrangePen1);CPoint point13=dc.MoveTo(190,11
30、0); /中心點(diǎn) dc.LineTo(x,y);/終點(diǎn)/恢復(fù)環(huán)境dc.SelectObject(pOldPen5); delete OrangePen1;/畫分針int x2,y2;if(m_second=270)m_minute+=6;i+;x2=int(190+48*cos(m_minute*pi/180);y2=int(110+48*sin(m_minute*pi/180);if (m_minute=360)m_minute=0;CPen *BlackPen=new CPen(PS_SOLID,3/*線寬*/, RGB(100, 250, 100)/*畫筆色*/);CPen *pOldP
31、en6=dc.SelectObject(BlackPen);CPoint point14=dc.MoveTo(190,110); /中心點(diǎn)dc.LineTo(x2,y2);/終點(diǎn)dc.SelectObject(pOldPen6); delete BlackPen;/畫時(shí)針int x3,y3;if(i%6=0)m_hour+=0.05;x3=int(190+40*cos(m_hour*pi/180);y3=int(110+40*sin(m_hour*pi/180);if(i=61)i=1;mm_hour+=30;if(m_hour=360)m_hour=0;mm_hour=0;CPen *Bla
32、ckPen3=new CPen(PS_SOLID,4/*線寬*/, RGB(0, 0, 200)/*畫筆色*/);CPen *pOldPen7=dc.SelectObject(BlackPen3);CPoint point15=dc.MoveTo(190,110); /中心點(diǎn)dc.LineTo(x3,y3);/終點(diǎn)dc.SelectObject(pOldPen7); delete BlackPen3;void CAaDlg:OnChangeEdit2() / TODO: If this is a RICHEDIT control, the control will not/ send this
33、 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/*flag=1;*/void CAaDlg:OnTimer(UINT nIDEvent) / TODO: Add your message handler code here
34、and/or call defaultif(nIDEvent=1)OnButton1();/ if(nIDEvent=2)/ PutOutCurrentTime();void CAaDlg:OnSettingTime() /設(shè)置時(shí)間按鈕/ TODO: Add your control notification handler code hereflag1=0;char ch15,ch25,ch35;GetDlgItem(IDC_EDIT2)->GetWindowText(ch1,5);GetDlgItem(IDC_EDIT3)->GetWindowText(ch2,5);GetDl
35、gItem(IDC_EDIT4)->GetWindowText(ch3,5);num1=atoi(ch1);num2=atoi(ch2);num3=atoi(ch3);m_second=-90+(num3-1)*6;/設(shè)置秒針初始時(shí)間位置m_minute=-90+num2*6;/設(shè)置分針初始時(shí)間位置m_hour=-90+num1*30+num2*30/60;/設(shè)置時(shí)針初始時(shí)間位置mm_hour=-90+num1*30+num2*30/60;if(num1>24|num2>61|num3>61)MessageBox("請(qǐng)輸入正確的時(shí)間");elseco
36、unt+; void CAaDlg:OnAdjustTime() /當(dāng)前時(shí)間按鈕/ TODO: Add your control notification handler code here int hour,minute,second; flag1=1; CTime t=CTime:GetCurrentTime(); hour=t.GetHour(); minute=t.GetMinute(); second=t.GetSecond(); if(second!=0)m_second=-90+(second-1)*6; if(minute!=0)m_minute=-90+minute*6; i
37、f(hour!=0) m_hour=-90+hour*30+minute*30/60; mm_hour=-90+hour*30+minute*30/60; /* count+;*/ OnButton1(); void CAaDlg:PutOutCurrentTime()/把表的時(shí)間輸出int minute,second;int hour=0;second=(m_second+96)/6;minute=(m_minute+90)/6;if(second<=59)SetDlgItemInt(IDC_EDIT4,second);elseSetDlgItemInt(IDC_EDIT4,secon
38、d-60);if(minute<=59)if(second<=59)SetDlgItemInt(IDC_EDIT3,minute);if(second=60)SetDlgItemInt(IDC_EDIT3,+minute); if(minute=60)SetDlgItemInt(IDC_EDIT3,minute-60);hour=(mm_hour+90)/30;if(flag1=0)/當(dāng)前時(shí)間按鈕沒有啟動(dòng),用的是設(shè)置時(shí)間按鈕if(minute<=59)SetDlgItemInt(IDC_EDIT2,hour);elseif(hour!=23)SetDlgItemInt(IDC
39、_EDIT2,+hour);elsehour=0;SetDlgItemInt(IDC_EDIT2,hour);if(flag1=1)/當(dāng)前時(shí)間按鈕啟動(dòng)if(minute<=59)SetDlgItemInt(IDC_EDIT2,hour);elseif(hour!=23)SetDlgItemInt(IDC_EDIT2,+hour);elsehour=0;SetDlgItemInt(IDC_EDIT2,hour);/ void CAaDlg:DrawLaughter()/ / / CWnd *pWnd=this;/GetDlgItem(IDC_WORK);/圖畫區(qū)域/ / CRect Rect;/ / pWnd->G
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國精密氣動(dòng)打標(biāo)機(jī)市場調(diào)查研究報(bào)告
- 2025年中國窗簾桿桿頭數(shù)據(jù)監(jiān)測研究報(bào)告
- 2025年中國堿溶增稠劑市場現(xiàn)狀分析及前景預(yù)測報(bào)告
- 2025年中國真空/氣壓高溫?zé)Y(jié)爐市場現(xiàn)狀分析及前景預(yù)測報(bào)告
- 2025年中國白云巖項(xiàng)目投資可行性研究報(bào)告
- 2025年中國電動(dòng)阻尼放線機(jī)項(xiàng)目投資可行性研究報(bào)告
- 2025年中國球形攝像機(jī)項(xiàng)目投資可行性研究報(bào)告
- 2025年中國豬尾型道絲器項(xiàng)目投資可行性研究報(bào)告
- 2025年中國煤層氣項(xiàng)目投資可行性研究報(bào)告
- 基金經(jīng)理考試試題及答案
- 大學(xué)體育與健康智慧樹知到期末考試答案章節(jié)答案2024年齊魯師范學(xué)院
- 2023-2024學(xué)年浙江省紹興市上虞市重點(diǎn)中學(xué)小升初數(shù)學(xué)入學(xué)考試卷含解析
- 小區(qū)消防移交物業(yè)協(xié)議書
- 【一例豬流行性腹瀉的診斷與治療實(shí)例探析4500字(論文)】
- 2024年正式離婚協(xié)議電子版(三篇)
- 中餐餐中服務(wù)服務(wù)流程培訓(xùn)
- 外賣行業(yè)交通安全培訓(xùn)
- 2024春期國開電大本科《現(xiàn)代漢語專題》在線形考(任務(wù)1至6)試題及答案
- 九三學(xué)社申請(qǐng)入社人員簡歷表
- 南京曉莊學(xué)院輔導(dǎo)員考試試題2024
- 神經(jīng)外科管道的護(hù)理
評(píng)論
0/150
提交評(píng)論