版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quá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/用外框進行試驗/計算長寬的變化比例/ 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è)置方框畫筆色 藍色/ 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() /第一個按鈕 畫鐘/ 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è)置方框畫筆色 藍色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軸的/先對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); /起點1dc.LineTo(190,35);/終點1CPoint point2=dc.MoveTo(190,200); /起
24、點2dc.LineTo(190,185);/終點2CPoint point3=dc.MoveTo(280,110); /起點3dc.LineTo(265,110);/終點3CPoint point4=dc.MoveTo(100,110); /起點4dc.LineTo(115,110);/終點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); /起點5dc.LineTo(190+35,110-nn);/終點
27、5CPoint point6=dc.MoveTo(190+mm,110-45); /起點6dc.LineTo(190+nn,110-35);/終點6CPoint point7=dc.MoveTo(190+mm,110+45); /起點7dc.LineTo(190+nn,110+35);/終點7CPoint point8=dc.MoveTo(190+45,110+mm); /起點8dc.LineTo(190+35,110+nn);/終點8CPoint point9=dc.MoveTo(190-45,110-mm); /起點9dc.LineTo(190-35,110-nn);/終點9CPoint
28、point10=dc.MoveTo(190-mm,110-45); /起點10dc.LineTo(190-nn,110-35);/終點10CPoint point11=dc.MoveTo(190-mm,110+45); /起點11dc.LineTo(190-nn,110+35);/終點11CPoint point12=dc.MoveTo(190-45,110+mm); /起點12dc.LineTo(190-35,110+nn);/終點12/恢復(fù)環(huán)境dc.SelectObject(pOldPen3); /輸出當(dāng)前時間if(flag=0)PutOutCurrentTime();SetTimer(1
29、,1000,0);/設(shè)定1秒鐘時間/畫秒針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); /中心點 dc.LineTo(x,y);/終點/恢復(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); /中心點dc.LineTo(x2,y2);/終點dc.SelectObject(pOldPen6); delete BlackPen;/畫時針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); /中心點dc.LineTo(x3,y3);/終點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è)置時間按鈕/ 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è)置秒針初始時間位置m_minute=-90+num2*6;/設(shè)置分針初始時間位置m_hour=-90+num1*30+num2*30/60;/設(shè)置時針初始時間位置mm_hour=-90+num1*30+num2*30/60;if(num1>24|num2>61|num3>61)MessageBox("請輸入正確的時間");elseco
36、unt+; void CAaDlg:OnAdjustTime() /當(dāng)前時間按鈕/ 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()/把表的時間輸出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è)置時間按鈕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)前時間按鈕啟動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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年安徽省宣城市郎溪縣縣直事業(yè)單位招聘40人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年安徽省合肥市煙草專賣局招聘高校畢業(yè)生9人高頻重點提升(共500題)附帶答案詳解
- 2025年安徽省六安市金安區(qū)部分事業(yè)單位招聘130人高頻重點提升(共500題)附帶答案詳解
- 2025年安徽省亳州市渦陽縣事業(yè)單位招聘39人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年安徽滁州市12345政務(wù)服務(wù)便民熱線崗位招聘20人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年安徽淮北市事業(yè)單位公開招聘工作人員159人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年安徽池州市市直事業(yè)單位招聘91人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年安徽宿州靈璧投資集團限公司公開招聘工作人員25名高頻重點提升(共500題)附帶答案詳解
- 2025年安徽宿州事業(yè)單位聯(lián)考高頻重點提升(共500題)附帶答案詳解
- 2025年安徽固鎮(zhèn)經(jīng)濟開發(fā)區(qū)管委會選聘人才7人歷年高頻重點提升(共500題)附帶答案詳解
- 船舶輔機:噴射泵
- 疼痛護理課件
- 農(nóng)民專業(yè)合作社章程參考
- 財務(wù)會計制度及核算軟件備案報告書
- 肌骨超聲簡介
- 神經(jīng)外科臨床實習(xí)教學(xué)計劃
- 基本光刻工藝流程
- 胸腔閉式引流護理-2023年中華護理學(xué)會團體標準
- 高中體育足球教學(xué)教案 全冊
- 藝術(shù)概論PPT完整全套教學(xué)課件
- 社團啦啦操訓(xùn)練計劃
評論
0/150
提交評論