VC开发程序实例_第1页
VC开发程序实例_第2页
VC开发程序实例_第3页
VC开发程序实例_第4页
VC开发程序实例_第5页
已阅读5页,还剩121页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

地形可视化实习要点二

Visualc++简单编程介绍

"开始”第©◎»眄MyTest-Mi..一)我QWC档|周8Hcroso£tP」@AdobePhoto..|⑥31nternet..❷RealPlay-:..||圜|(「〈♦.QI9;皎

聃|GetConvexHull11国曝

®l曲

ApplicationtypeofMyTest:

MultipleDocumentInterfaceApplicationtargeting:

Win32

Classestobecreated:

Application:CMyTestAppinMyTest.handMyTestcpp

Frame:CMainFrameinMainFrm.handMainFrm.cpp

MDIChildFrame:CChildFrameinChildFrm.handChildFrm.cpp

Document:CMyTestDocinMyTestDoc.handMyTestDoc.cpp

View:CMyTestViewinMyTestView.handMyTestView.t^p

Features:

+Initialtoolbarinmainframe

+Initialstatusbarinmainframe

+PrintingandPrintPreviewsupportinview

+3DControls

+UsessharedDLLimplementation(MFC42.DLL)

+ActiveXControlssupportenabled

+Localizabletextin:

中文仲国1

ProjectDirectory:

D:\MyTest

Cancel

Ready

"开始「第©◎»l厨MyTest-Mi..一,我的文档I国MicrosoftP|QAdobePhoto.©3工ntexnet..RealPlayer:.j哥I❷直目|9:44

"开始”第©◎»眄MyTest-Mi..一,我QWC档|网MicrosoftP|@AdobePhoto.|©3工ntexnet..▼1❷RealPlayer:...||画]

(日♦.QI。;45

lyTest-licrosoftVisualC++

FileEditViewInsertProjectBuildToolsVindowHelp

窗|.x.题扃二一一「吗区1西|GetConvexHull▼仍必Lf国喈富。嗖?片/*〃11为限

(GlobalsJ(AllglobalmembersjJ||Nomembers-CreateNewClass...)?X、▼悭曜昌!副通

--------------------------------------------------------------------------ijJx

B《

E飞CAboutDIg

t亘飞CChildFrame

t!.巳CMainFrame

+*,•CMyTestApp

t1飞CMyTestDoc

+飞CMyTestView

SLJGlobals

EClassView]幽ResourceView]圉FileView]

4q

JJ.LRBui类Id/Debug\FindmFiles1XFindinFiles7.\ResultsJtJ_]►|-

Ready

才开始|I劭0易》|MyTest-Mi..~~一,我觇T档|罔桁croso£tP•|@AdobePhoto.@31ntexnet..▼[❷RealPlayer.|哥|(|«❷廷目|9:48

***/ByTest一licrosoftVisualC+4-[iyTestView.cpp]

中MyTestView.cppD.\fflyTest\MyTestView.cpp

臼摩MyTestclasses//}}AFXJ1SGJ1AP

®*4CAboutDIg//Standardprintingcommands

由■胃CChildFrame0H_C0MMAND(ID_FILE_PRINT,CUiew::OnFilePrint)

ONZCOHHAND(ID^FILE^PRINT_DIRECT,CUiew::OnFilePrint)

团■巴CMainFrame

OHZCOMMAND(ID^FILE^PRINTZPREUIEW,CUiew::OnFilePrintPreuiew)

S飞CMyTesSppENDJ1ESSAGEJ1AP()

3CMyTestDoc

日■3CMyTestView/////////////////////////////////////////////////////////////////////////////

AssertValidp//CI'1yTestUiev>construction/destruction

CMyTestView|

♦~CMyTestVievMyTestUiew::CMyTestUiew()

♦Dump(CDump

0:addconstructioncodehere

♦GetDocument

OnBeginPrinti

♦OnDraw(CDC双击函数名,打开cpp'文

$.OnEndPrintiniCMyTestUiew::^CMyTestUiei^)

为OnPreparePri件,定位到该函数体/

•PreCreateWin

®LJGlobals

BOOLCMyTestUiew::PreCreateWindow(CREATESTRUCT&cs)

//TODO:ModifytheWindowclassorstyleshe»-ebymodifying

//theCREATESTRUCTcs

returnCUieu::PreCreateWindow(cs);

11/////////////////////////////////////////////////////////////////////////////

r*<*M*.*v*——JL.IIJ---一一•

Re...凰Fil…

缩放源程序窗口

J►Build/Debug'FindinFiles14FindinFilgs2XR&suLts

Ready

开始|缪©眉》11©9MyTest-Mi...」我的文档IJE]MicrosoftP..|QAdobePhoto..|眉3工nternet..4^RealPlayer:...|回|,~10:21

***/lyTest一licrosoftVisualC++-|g|x|

FileEditViewinsertProjectBuildToolsWindowjjelp

置辞「能?,—M国留聃河etConvexHull2J«u炉电毛力图答厩电魄『中/*》、到国取

|CMyTestViewclassmembers)▼^CMyTestView圜:盾!蓟州

J*1

臼尊MyTestclasses

®pCAboutDIg

//>>AFX_MSG_HAP3

由■胃CChildFrameclassCMyTestUiew:publicCUiew//Standardprintingcommands

由FCMainFrameON_COI1HftND(ID_F1LE_PRINT,CUiew::OnFilePri

S飞CMyTesSppprotected://createFromserializationonlyON二COMMAND(ID二F1LE二PRINT_DIRECT,CUidu::0r

3CMyTestDocCMyTestUiew();ON二COMMAND(ID二FILE二PRINT二PREUIEW,CUiew::(

DECLARE_DVNCREATE(CMyTestUiew)END_MESSAGE_MAP()~/

日■3CMyTestView

♦AssertValii

//Attributes/////////////////////////////////////////////y

9»|CMyTestVi

public://CMyTestUiewconstruction/destructj^on

♦〜CMyTestVCMyTestDoc*GetDocunent();

♦Dump(CDuCMyTestUiew::CMyTestUiev/()

♦GetDocum//Operations

OnBeginPipublic://TODO:addconstructioncode7here

♦OnDraw(C[

//Ouerrides

OnEndPrin

//ClassWizardgenerateduirtualFunctionou

小♦OnPrepare

//<<AFX_UIRTUfiL(CMyTestUiew)CMyTestUiew:z^CMyTestUiewt)

•PreCreateSpublic:

田口GlobalsuirtualuoidOnDraw(CDC*pDC);//ouerriddei

uirtualBOOLPreCreateWindow(CREfiTESTRUCT6c:

protected:BOOLCMyTestUiew::PreCreatet|{ndow(CREATESTRUCl

virtualBOOLOnPreparePrinting(CPrintInFo*p

uirtualvoidOnBeginPrinting(CDC*pDCvCPrin//TODO:ModifytheWindowclassorstyle*

virtualuoidOnEndPrintingCCDC*pDCyCPrintli//theCREATESTRUCTqs

〃}}AFXUIRTUAL

returnCUiew::PreCre^teV^indov/(cs);

►〃Implementation

回N…

圄Fi...L11U2d

缩放源程序窗口

11►Build/DebugXFindinFiles1XFindinFiles2XResultsj|<|

ReadyILn16,Col19|REC[COL|OVR|READ

开始|缪眉》」我的文档

©||©9MyTest-Mi...I同MicrosoftP..|⑥AdobePhoto.3Internet.❷RealPlayer:...I|圜,回|?[«10:23

***/lyTest一licrosoftVisualC++-|g|x|

FileEditViewinsertProjectBuildToolsWindowjjelp

置4IH7・电i=0因留%|GetConvexHull三]|扁k电A4国吟蜜{)®m片"〃句为暇

|CMyTestViewEgilclassmembers)▼|[8.CMyTestView三]鱼,季圜县!顼州

J*1■yTestViev.h&■yTirstViewcpg>-1□!x|

臼尊MyTestclasses寺CMyTestViewICView

®*4CAboutDIg

3//>>AFX_MSG_HAP

由■胃CChildFrame//Ouerrides//Standardprintingcommands

由FCMainFrame//ClasswizardgenerateduirtualFunctionou(ON_COI1HftND(ID_F1LE_PRINT,CUiew::OnFilePri

S飞CMyTesSpp//<<AFX_UIRTUAL(CMyTestUiew)ON二COMMAND(ID二F1LE二PRINT_DIRECT,CUiew::0r

3CMyTestDocpublic:ON二COMMAND(ID二FILE二PRINT二PREUIE*CUiew::(

uirtualuoidOnDraw(CDC*pDC);//ouerriddei

日■3CMyTestViewENDMESSAGEJIAPO

uirtualBOOLPreCreateWindow(CREATESTRUCT&c:

♦AssertValii

protected://///////////////////////////////////////////y

CMyTestViuirtualBOOLOnPreparePrinting(CPrintInFo*p//CMyTestUiewconstruction/destruction

♦〜CMyTestV

virtualuoidOnBeginPrinting(CDC»pDCvCPrin

♦Dump(CDuuirtualuoidOnEndPrinting(CDC*pDC,CPrintliCMyTestUiew::CMyTestUiev/()

♦GetDocum//>>AFX_UIRTUfiL

OnBeginPi//TODO:addconstructioncodehere

♦OnDraw(C(Implementation

public:

为OnEndPrin

uirtual^CMyTestUiew();

为OnPrepare

ttiFdef_DEBUGCMyTestUiew:z^CMyTestUiewt)

•PreCreateSuirtualuoidftssertUalid()const;

®QGlobalsuirtualuoidDump(CDunpContext&(1c)const;

ttendiF

BOOLCMyTestUiew::PreCreateWindow(CREATESTRUCl

protected:

//TODO:ModifytheWindowclassorstyle*

//GeneratednessagenapFunctions//theCREATESTRUCTcs

protected:

//<<AFX_MSG(CMyTestUiew)returnCUiew::PreCreateV^indow(cs);

►//NOTE-theClasswizardwilladdand门周}

hONOTPhITmhst-nnticooir»t*hoco

凰Fi…L11UL11U2d

.

IZEkBuild/:D®huEkFibdiirFileis1XFindixiFilQs2'Results"'4||

2?

Ready[Ln16,Col19|REC[COL|OVR|READ

j国MicrosoftP..10AdobePhoto.163▼|。RealPlayer:..||曷|②|?[

"开始|◎⑥油"11©©MyTest-Mi...」我的文档Internet.«10:27

***/lyTest一licrosoftVisualC++-|g|x|

FileEditViewinsertProjectBuildToolsWindowjjelp

置;自易图|>船里|工”口;因杏聃|GetConvexHull-3I'M少场A冷国曾蜜{}眠期%/*〃引c旬限

lewclassmembers)^]CMyTestView三I区,季圜县!顼州

二」X

EiSp]MyTestclasses

3B飞CAboutDIg//>>AFX_MSG_HAP

由■:CChildFrame//Ouerrides-//Standardprintingcommands3

田CMainFrame//ClasswizardgenerateduirtualFunctionouiON_COI1HftND(ID_F1LE_PRINT,CUiew::OnFilePri

田飞CMyTesSpp//<<AFX_UIRTUAL(CMyTestUiew)ON二COMMAND(ID二F1LE二PRINT_DIRECT,CUiew::0r

田,1;CMyTestDocpublic:ON二COMMAND(ID二FILE二PRINT二PREUIE*CUiew::(

virtualuoidOnDraw(CDC*pDC);//ouerriddei

日■,CMyTestViewENDMESSAGEJIAPO

uirtualBOOLPreCreateWindow(CREATESTRUCT&c:

♦AssertValii

protected://///////////////////////////////////////////y

钏CMyTestViuirtualBOOLOnPreparePrinting(CPrintInFo*p//CMyTestUiewconstruction/destruction

♦〜CMyTestV

virtualuoidOnBeginPrinting(CDC»pDCvCPrin

♦Dump(CDuuirtualuoidOnEndPrinting(CDC*pDC,CPrintliCMyTestUiew::CMyTestUiev/()

♦GetDocum//>>AFX_UIRTUfiL

OnBeginPi//TODO:addconstructioncodehere

♦OnDraw(C[//Inple析构函数

%OnEndPrin

uirtual^CMyTestUiew();

gOnPrepare

ttiFDEBUGCMyTestUiew:z^CMyTestUiewt)

•PreCreateSuioidAid()const;

ElQGlobalsuirtualuoidDump(CDunpContext&j)const;

ttendiF

ateWindow(CREATESTRUCl

protected:

//TODO:ModifytheWindowclassorstyle*

//GeneratednessagenapFunctions//theCREATESTRUCTcs

protected:

//<<AFX_MSG(CMyTestUiew)returnCUiew::PreCreateV^indov/(cs);

41►//NOTE-theClasswizardwilladdandr«।

hONOTPhITmhst-nnticooir»t*hoco

弱R…圄Fi...L11UL11U2d

ABuild/"DebugtFindinFiles13FindinFiles2\Results】<|2?

Ready[Ln16,Col19(REC[COL|OVR(READ

上开始I缪0Q»I【SMyTest-Mi…」我的文档I周MicrosoftP..J0AdobePhoto.3Internet.▼]RealPlayer:.I哥回I10:27

iyTest-[lyTestl]

常用消息与函数

■消息函数

♦与ID直接挂钩

♦不与ID直接挂钩

■类成员函数(自定义函数)

***/ByTest一licrosoftVisualC+4-[iyTestView.cpp]-|g|X|

l?l£ileEditView工nsertProjectguildlools也-|g|x|

固辱甚能宅国西聃

GA1-I0|GetConvexHull|M少场A冷国曾唱{}崛a%/*〃2c旬啾

jCMyTestView^||(Allclassmembers)^||^OnPrepareDC奥▼骸圜马!:虱州

J*1中MyTestView.cppD:\MyTest\MyTestView.cpp

臼尊MyTestclassesCUievj::AssertUalid();

®*4CAboutDIg

由■胃CChildFrame

uoidCMyTestUievj::Duiup(CDumpContext&de)const

由FCMainFrame

S飞CMyTesSppCUiew::Dunp(dc);

3CMyTestDoc

日弋CMyTestView

AssertValiiCMyTestDoc*CMyTestUiew::GetDocument()//non-debuguersionisinline

爽CMyTestVi<

♦〜CMyTesWASSERT(mpDocunent->IsKindOf:(RUNTIME_CLASS(CMyTestDoc)));

♦Dump(CDureturn(CMyTestDoc*)npDocument;

♦GetDocum}

ttendif//__DEBUG

OnBeginPi

♦OnDraw(C[/////////////////////////////////////////////////////////////////////////////

OnEndPrin〃CMuTestUiewmessaqehandlers

♦OnPrepare

2*OnPrepareuoidCMyTestUiew::OnPrepareDC(CDC*-iDC,CPrintlnFo*plnfo)

♦PreCreateS

由LJGlobals//TODO:Addyourspecializedcodehereand/orcallthebaseclass

CUievj::OnPrepareDC(pDC9plnfo);

一T』准备画图设备DC,每次刷新窗口时由程序自动调用立

二皿st4一0"。山|),为DnOraw准备DC,然后将^pDC传递给OnDraw画图

\<I►BuildkDepug入FindinFiles11FindinFilers2XResults】|“|,J

ReadyILn110^01|HEC[COL|OVR|READ

开始|缪©眉》|MyTest-Mi...」我的文档j国MicrosoftP..10AdobePhoto.163Internet.▼|©WindowsWed..|圜,⑦|?[«11:33

I、VisualC++6基本操作

4、绘图方式与坐标映射

voidC1cst\jew:'OnrrcpurcOC(C1.)CpD(,(.±rintliilo*

CRectrc;

GetClientRect(&rc);〃获得视口矩形

intnWidth=10000;〃窗口关小

intnHeight=18000;

pDC->SetMapMode(MM_ISOTROPIC);〃映射模式

pDC->SetViewportOrg((rc.left+rc.right)/!,(rc.top+ix:botton^/^);〃视口原点

pDC->SetWindowOrg(0,0);〃窗口原点

pDC->SetViewportExt(rc.Width(),-rc.HeightO);〃视口宽、

pDC->SetWindowExt(nWidth,nHeight);〃窗口宽高

CViev::OnPrepareD('(pDC,plnfo);

}

就绪I一藏竽耐

,开始|◎⑥眉》ISMyTest-…|」我的文档|回地形可视.|⑥AdobePh.|£21ntem…J©Windows|项MyTest|哥|②|?k12:01

***/ByTest-licrosoftVisualC++-[ByTestViev.cpp■]-|g|X|

・区I£ileEditViewInsertProjectguildToolsJ/indowHelp-Il5|X|

HP目|/电■|C:,|厄回官埠|GetConvexHuH-3|5|帕内.用图鸳电电魄?q/*〃11阁间

jcMyTestView-classmembers)▼]1,OnPrepareDC-虱▼口检圜士••班)

J*1中CMyTestView.OnPrepareDCvoidCMyTestView:.OnPrepareDC(CDC*pDC,CPrintlnfo*plnfo){

臼尊MyTestclassesCUiew::Dunp(dc);

®pCAboutDIg

由■胃CChildFrame

CMyTestDoc*CMyTestUievi::GetDocument()//non-debuguersionisinline

由FCMainFrame

S飞CMyTesSppASSERT(n_POocurnent->IsKindOF(RUNTIME_CLASS(CMyTestDoc)));

3CMyTestDocreturn(CMyTestDoc*)H_pDocument;

日弋CMyTestView

AssertValiittendiF//__DEBUG

爽CMyTestVi

♦〜CMyTesW/////////////////////////////////////////////烁来妁地图出标系的原点

♦Dump(CDu//CMyTestUiewmessagehandlers

♦GetDocum

uoidCMyTestUiew::OnPrepareDC(CDC*pDC,A/二

OnBeginPiy

♦OnDraw(C[//TODO:Addyourspecializedcodehereano/orcallthebaseclass

OnEndPrinCRectre;

♦OnPrepareGetClieniRect(&「,):〃获得视口矩形„__,tr.t、r

2*OnPrepareintnWidth=18060;〃窗口大小IS\占

♦PreCreateSintnHeight=18080;/3qF'i'*I-l'>

由LJGlobalspDC->SetMapMode(MMANISOTROPICjT〃映射模式\f

li)OC->SetUiewoortOra((「「.left*;GiW孤♦潭吧ttQFQ/2):〃视口原点

pDC->SetWindowOrg(0,0);〃密日康点

pDC->SetUiewportExt(rc.Width()»-rc.HeightO);〃视口宽、高

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论