欢迎来到天天文库
浏览记录
ID:34745024
大小:134.63 KB
页数:7页
时间:2019-03-10
《创建插入符输出不同效果的文字》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、创建插入符、输出不同效果的文字创建一个MFC单文档应用程序一.创建插入符在窗口创建完成之后,再创建插入符,在View类当中去完成,增加一个WindowsMessageHandle…..,WM_CREATE消息处理函数。1.创建一个文字插入符CClientDCdc(this);//构造一个DC/*TheCClientDCclassisderivedfromCDCandtakescareofcallingtheWindowsfunctionsGetDCatconstructiontimeandReleaseDCatdestructiontime.Thismeansthat
2、thedevicecontextassociatedwithaCClientDCobjectistheclientareaofawindow.*/TEXTMETRICtm;/*TheTEXTMETRICstructurecontainsbasicinformationaboutaphysicalfont.Allsizesaregiveninlogicalunits;thatis,theydependonthecurrentmappingmodeofthedisplaycontext.typedefstructtagTEXTMETRIC{//tmLONGtmHeight
3、;LONGtmAscent;LONGtmDescent;LONGtmInternalLeading;LONGtmExternalLeading;LONGtmAveCharWidth;LONGtmMaxCharWidth;LONGtmWeight;LONGtmOverhang;LONGtmDigitizedAspectX;LONGtmDigitizedAspectY;BCHARtmFirstChar;BCHARtmLastChar;BCHARtmDefaultChar;BCHARtmBreakChar;BYTEtmItalic;BYTEtmUnderlined;BYTE
4、tmStruckOut;BYTEtmPitchAndFamily;BYTEtmCharSet;}TEXTMETRIC;*/dc.GetTextMetrics(&tm);/*TheGetTextMetricsfunctionfillsthespecifiedbufferwiththemetricsforthecurrentlyselectedfont.BOOLGetTextMetrics(HDChdc,//handletodevicecontextLPTEXTMETRIClptm//pointertotextmetricsstructure);*/CreateSolid
5、Caret(tm.tmAveCharWidth/8,tm.tmHeight);//创建文字插入符/*voidCreateSolidCaret(intnWidth,intnHeight);ParametersnWidthSpecifiesthewidthofthecaret(inlogicalunits).Ifthisparameteris0,thewidthissettothesystem-definedwindow-borderwidth.nHeightSpecifiestheheightofthecaret(inlogicalunits).Ifthisparame
6、teris0,theheightissettothesystem-definedwindow-borderheight.Createsasolidrectangleforthesystemcaretandclaimsownershipofthecaret.Thecaretshapecanbealineorblock.*/ShowCaret();/*TheShowCaretfunctionmakesthecaretvisibleonthescreenatthecaret'scurrentposition.Whenthecaretbecomesvisible,itbegi
7、nsflashingautomatically.BOOLShowCaret(HWNDhWnd//handleofwindowwithcaret);*/2.创建一个位图插入符在View类中加入一个CBitmap成员变量,//CBitmapbitmap;//这个对象与资源相关,析构时就删除了bitmap.LoadBitmap(IDB_BITMAP1);//IDB_BITMAP1是在资源中导入的位图/*BOOLLoadBitmap(LPCTSTRlpszResourceName);BOOLLoadBitmap(UINTnIDResource);Return
此文档下载收益归作者所有