版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、/MainFrm.cpp : implementation of the CMainFrame class#include "stdafx.h"#include "My_drown.h"#include "MainFrm.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifIMPLEMENT_DYNCREATE(CMainFrame, CFrameWndBEGIN_MESSAGE_MAP(CMainFrame,
2、 CFrameWnd/AFX_MSG_MAP(CMainFrame/ NOTE - the ClassWizard will add and remove mapping macros here./ DO NOT EDIT what you see in these blocks of generated code !ON_WM_CREATE(/AFX_MSG_MAPEND_MESSAGE_MAP(static UINT indicators =ID_SEPARATOR, / status line indicatorID_INDICATOR_CAPS,ID_INDICATOR_NUM,ID_
3、INDICATOR_SCRL,;CMainFrame:CMainFrame(CMainFrame:CMainFrame(int CMainFrame:OnCreate(LPCREATESTRUCT lpCreateStructif (CFrameWnd:OnCreate(lpCreateStruct = -1return -1;if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE
4、_DYNAMIC |!m_wndToolBar.LoadToolBar(IDR_MAINFRAMETRACE0("Failed to create toolbarn"return -1; / fail to createif (!m_wndStatusBar.Create(this |!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators/sizeof(UINTTRACE0("Failed to create status barn"return -1; / fail to create/
5、TODO: Delete these three lines if you don't want the toolbar to/ be dockablem_wndToolBar.EnableDocking(CBRS_ALIGN_ANY;EnableDocking(CBRS_ALIGN_ANY;DockControlBar(&m_wndToolBar;return 0;BOOL CMainFrame:PreCreateWindow(CREATESTRUCT& csif( !CFrameWnd:PreCreateWindow(cs return FALSE;/ TODO:
6、Modify the Window class or styles here by modifying/ the CREATESTRUCT csreturn TRUE;/ CMainFrame diagnostics#ifdef _DEBUGvoid CMainFrame:AssertValid( constCFrameWnd:AssertValid(;void CMainFrame:Dump(CDumpContext& dc constCFrameWnd:Dump(dc;#endif /_DEBUG/ CMainFrame message handlersCLevelingAdjus
7、t level;level.resultfp=fp;level.Inputdata(datafile;level.Printdata(;level.LS_Adjustment(;fclose(fp;/ My_drownView.cpp : implementation of the CMy_drownView class/ #include "stdafx.h"#include "My_drown.h"#include "My_drownDoc.h"#include "My_drownView.h"#include
8、"math.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CMy_drownViewIMPLEMENT_DYNCREATE(CMy_drownView, CViewBEGIN_MESSAGE_MAP(CMy_drownView, CView/AFX_MSG_MAP(CMy_drownViewON_WM_LBUTTONDOWN(ON_WM_MOUSEMOVE(ON_WM_LBUTTONUP(/AFX_MSG_MAP/ Standard pri
9、nting commandsON_COMMAND(ID_FILE_PRINT, CView:OnFilePrintON_COMMAND(ID_FILE_PRINT_DIRECT, CView:OnFilePrintON_COMMAND(ID_FILE_PRINT_PREVIEW, CView:OnFilePrintPreview END_MESSAGE_MAP(/ CMy_drownView construction/destructionCMy_drownView:CMy_drownView(/ TODO: add construction code herem_bDragging = fa
10、lse;BOOL CMy_drownView:PreCreateWindow(CREATESTRUCT& cs/ TODO: Modify the Window class or styles here by modifying/ the CREATESTRUCT csreturn CView:PreCreateWindow(cs;/ CMy_drownView drawingvoid CMy_drownView:OnDraw(CDC* pDCCMy_drownDoc* pDoc = GetDocument(;ASSERT_VALID(pDoc;/設(shè)置原點的坐標pDC->SetM
11、apMode(MM_TEXT;pDC->Rectangle(CRect(50, 50, 100, 100; / 直接基于屏幕繪制pDC->SetMapMode(MM_TEXT;pDC->SetWindowOrg(50, 50; /屏幕左上角的坐標設(shè)置為(50, 50 pDC->SetViewportOrg(50,50; / 當前原點位置移動到(50, 50的位置 pDC->Rectangle(CRect(50, 50, 100, 100;pDC->SetMapMode(MM_TEXT;pDC->SetViewportOrg(50,50;/當前原點位置移
12、動到(50, 50的位置pDC->Rectangle(CRect(50, 50, 100, 100;pDC->SetMapMode(MM_TEXT;pDC->SetViewportOrg(50,50; / 當前原點位置移動到(50, 50的位置pDC->SetWindowOrg(50, 50; / 當前的原點坐標設(shè)置為(50, 50pDC->Rectangle(CRect(50, 50, 100, 100;COLORREF rgbBkClr = RGB(192,192,192; / 定義灰色 pDC->SetBkColor(rgbBkClr; / 背景色為灰
13、色pDC->SetBkColor(RGB(192,192,192; / 背景色為灰色pDC->SetTextColor(RGB(0,0,0; / 文本顏色為蘭色/編寫一個SDI應(yīng)用程序,繪制不同風格、寬度和顏色的直線CPen *pPenOld, PenNew;int nPenStyle= PS_SOLID, / 實線PS_DOT, / 點線PS_DASH, / 虛線PS_DASHDOT,/ 點劃線PS_DASHDOTDOT, / 雙點劃線PS_NULL, / 空的邊框PS_INSIDEFRAME, / 邊框?qū)嵕€;char *strStyle="Solid", &
14、quot;Dot", "Dash", "DashDot","DashDotDot", "Null", "InsideFrame"pDC->TextOut(60, 10, "用不同樣式的畫筆繪圖"for(int i=0; i<7; i+ / 用不同樣式的畫筆繪圖 if(PenNew.CreatePen(nPenStylei,1,RGB(0,0,0 /創(chuàng)建畫筆pPenOld=pDC->SelectObject(&PenNew; / 選擇畫筆pD
15、C->TextOut(10,30+20*i,strStylei;pDC->MoveTo(100,40+20*i;pDC->LineTo(200,40+20*i;pDC->SelectObject(pPenOld; / 恢復(fù)原來的畫筆PenNew.DeleteObject(; / 刪除底層的GDI對象else MessageBox("不能創(chuàng)建畫筆!"char *strWidth="1", "2", "3", "4", "5", "6"
16、, "7"pDC->TextOut(260, 10, "用不同寬度的畫筆繪圖"for(i=0; i<7; i+ / 用不同寬度的畫筆繪圖if(PenNew.CreatePen(PS_SOLID,i+1,RGB(0,0,0 / 創(chuàng)建畫筆pPenOld=pDC->SelectObject(&PenNew; / 選擇畫筆pDC->TextOut(260, 30+20*i,strWidthi;pDC->MoveTo(300, 40+20*i;pDC->LineTo(400, 40+20*i;pDC->Select
17、Object(pPenOld; / 恢復(fù)原來的畫筆PenNew.DeleteObject(; / 刪除底層的GDI對象else MessageBox("不能創(chuàng)建畫筆!"char *strColor="紅","綠","藍","黃","紫","青","灰"COLORREF rgbPenClr=RGB(255,0,0, RGB(0,255,0,RGB(0,0,255, RGB(255,255,0, RGB(255,0,255,RGB(0,25
18、5,255, RGB(192,192,192;pDC->TextOut(460,10,"用不同顏色的畫筆繪圖"for(i=0; i<7; i+ / 用不同顏色的畫筆繪圖CPen *pPenNew=new CPen(PS_SOLID,2,rgbPenClri;/ 創(chuàng)建畫筆的另一種方法pPenOld=pDC->SelectObject(pPenNew; / 選擇創(chuàng)建的畫筆pDC->TextOut(460,30+20*i, strColori;pDC->MoveTo(500,40+20*i;pDC->LineTo(600,40+20*i;pDC
19、->SelectObject(pPenOld; / 恢復(fù)原來的畫筆delete pPenNew; / 自動刪除底層的GDI對象CMy_drownDoc* pDoc = GetDocument(;ASSERT_VALID(pDoc;pDC->SetTextColor(RGB(128,256,256;pDC->TextOut(300,20," 歡迎您使用!"pDC->TextOut(20,60,"直線:"pDC->MoveTo(20,90;pDC->LineTo(160,90;pDC->TextOut(20,110,
20、"折線:"POINT polylinepoint4=110,120,120,100, 150,150,160,130;pDC->Polyline(polylinepoint,4;int i , j=0 ;pDC->TextOut(20,200,"橢圓:"for (i=0;i<6;i+pDC->Arc(150-5*i,200-5*i,50+5*i,200+5*i,10+5*i,225,10+5*i,225;pDC->TextOut(20,240,"圓弧、圓、橢圓:"for (i=3;i<6;i+ pD
21、C->Arc(150-10*i, 300-10*i, 30+10*i, 300+10*i, (int30+10*i*cos(60*3.1415926/180,(int300+10*i*sin(60*3.1415926/180,(int30+10*i*cos(60*3.1415926/180,(int300-10*i*sin(60*3.1415926/180; pDC->Arc(150-10*i, 300-10*i, 30+10*i, 300+10*i, (int150-10*i*cos(60*3.1415926/180, (int300-10*i*sin(60*3.1415926/
22、180, (int150-10*i*cos(60*3.1415926/180, (int300+10*i*sin(60*3.1415926/180; /繪制多邊形 pDC->TextOut(20,125,"多邊形:" POINT polygonPts3=75,100,100,150,105,120; pDC->Polygon(polygonPts,3; /繪制 Bezier 曲線 POINT polyBezier4=220,120,360,240,420,360,560,420; pDC->SetPixel(220,120,RGB(256,0,0; pDC
23、->SetPixel(360,240,RGB(0,256,0; pDC->SetPixel(420,360,RGB(0,0,256; pDC->SetPixel(560,420,RGB(128,256,128; pDC->Polyline(polyBezier,4; pDC->PolyBezier(polyBezier,4; /用不同樣式的畫筆 intnPenStyle=PS_SOLID,PS_DASH,PS_DOT,PS_DASHDOT,PS_DASHDOTDOT,PS_NULL,P S_INSIDEFRAME; CPen *pNewPen; CPen *pOl
24、dPen; for (i=0;i<7;i+ /構(gòu)造新筆 pNewPen=new CPen; if (pNewPen->CreatePen(nPenStylei,1,RGB(0,0,0 pOldPen=pDC->SelectObject(pNewPen; /選擇新筆,并保存舊筆 /畫直線 pDC->MoveTo(20,360+i*20; pDC->LineTo(160,360+i*20; /恢復(fù)原有的筆 pDC->SelectObject(pOldPen; else /刪除新筆 delete pNewPen; /畫刷 pDC->TextOut(600,8
25、0,"矩形填充" CBrush *pNewBrush; CBrush *pOldBrush; pNewBrush=new CBrush; /出錯提示 AfxMessageBox("CreatePen Erroe!" if (pNewBrush->CreateSolidBrush(RGB(255,128,0 /選擇新畫刷 pOldBrush=pDC->SelectObject(pNewBrush; /繪制矩形 pDC->Rectangle(600,100,650,500; /恢復(fù)原有畫刷 pDC->SelectObject(pOld
26、Brush; delete pNewBrush; / TODO: add draw code for native data here / / TODO: add draw code for native data here / CMy_drownView printing BOOL CMy_drownView:OnPreparePrinting(CPrintInfo* pInfo / default preparation return DoPreparePrinting(pInfo; void CMy_drownView:OnBeginPrinting(CDC* /*pDC*/, CPri
27、ntInfo* /*pInfo*/ / TODO: add extra initialization before printing void CMy_drownView:OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/ / TODO: add cleanup after printing / / CMy_drownView diagnostics #ifdef _DEBUG void CMy_drownView:AssertValid( const CView:AssertValid(; void CMy_drownView:Dump(CDu
28、mpContext& dc const CView:Dump(dc; CMy_drownDoc* CMy_drownView:GetDocument( / non-debug version is inline ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy_drownDoc; return (CMy_drownDoc*m_pDocument; #endif /_DEBUG / / CMy_drownView message handlers void CMy_drownView:OnLButtonDown(UINT nFlags, CPoint point / TODO: Add
溫馨提示
- 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)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年體育賽事贊助與廣告授權(quán)合同
- 2024年廣告圍擋工程設(shè)計與安裝合同
- 幼兒園聽課心得體會萬能模板(6篇)
- 2024年技術(shù)合同:技術(shù)開發(fā)與合作條款詳解
- 2024年婚姻法律咨詢合同
- 2024年教育費用分期付款協(xié)議
- 2024年斷橋鋁門窗專屬定制協(xié)議
- 工程監(jiān)理個人年度工作計劃5篇
- 入職員工培訓(xùn)心得體會13篇
- 2024年委托開發(fā)合同標的為移動應(yīng)用
- 2024新外研版七年級上冊課本重點知識點及范文歸納
- 河北省石家莊市2023-2024學(xué)年七年級上學(xué)期語文期中考試試卷(含答案)
- 期中 (試題) -2024-2025學(xué)年譯林版(三起)(2024)英語三年級上冊
- 八年級上冊 主題1-“外賣的調(diào)查研究”綜合實踐活動考察探究教學(xué)設(shè)計
- 2023年江蘇常州中考滿分作文《方寸之間天地大》4
- 部編二年級上冊道德與法治全冊教案(共16課)
- 廣州數(shù)據(jù)資產(chǎn)管理及入表工作指引 2024
- 消防噴淋安裝承包合同(2024版)
- “雙減”小學(xué)語文六年級上冊單元作業(yè)設(shè)計案例
- 阿里巴巴員工紀律制度
- 商業(yè)銀行旺季營銷開門紅
評論
0/150
提交評論