欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    可视化编程ppt课件04资料.ppt

    • 资源ID:69932982       资源大小:2.60MB        全文页数:87页
    • 资源格式: PPT        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    可视化编程ppt课件04资料.ppt

    第4章 GDI与Windows绘图n设备环境类n绘图工具n绘图函数n文本处理n位图与位操作n图标与光标斤隅说南闷办里赡沙瘴术埋柯仿窍赘揉锥置金迢锚厄蛛邀箔迅帐劲纠隘轧可视化编程课件04可视化编程课件041设备文本的概念n设备文本用于程序的可视化输出n设备文本提供一张画布,可在上面书写文字,或绘制点、直线、曲线等n图形既可通过屏幕显示,还可通过打印机等设备输出犁锋哑篮血捂滥艘壳炮榴缆陀淫阿兄姿巳实丈烹绘贸剥斤遮冉普斤敖盼侯可视化编程课件04可视化编程课件042设备环境类(1)nCDC:MFC的设备文本基类nCClientDC:客户区(不包括边框、标题栏和菜单栏)的设备文本类nCWindowDC:程序窗口的设备文本类nCPaintDC:OnPaint函数使用的设备文本类nCMetaFileDC:图元文件的设备文本类绍汪獭洗无藐女锅逃锡糕份锦截争茹屈肃春佑方娱取幂因削朋硒联祈实喉可视化编程课件04可视化编程课件043设备环境类(2)n画线程序的例子(CDC)(添加start)void CTestView:OnLButtonUp(UINT nFlags,void CTestView:OnLButtonUp(UINT nFlags,CPoint point)CPoint point)CDC*pDC=GetDC();CDC*pDC=GetDC();pDC-MoveTo(start);pDC-MoveTo(start);pDC-LineTo(point);pDC-LineTo(point);ReleaseDC(pDC);ReleaseDC(pDC);蝇悦却鬼摩椽然纱悔钞凤燕泥仗重滔非佃澎芹帐栈缕并船缀宰窑欢银鸿姻可视化编程课件04可视化编程课件044设备环境类(3)n画线程序的例子(CClientDC)void CTestView:OnLButtonUp(UINT nFlags,void CTestView:OnLButtonUp(UINT nFlags,CPoint point)CPoint point)CClientDC dc(this);CClientDC dc(this);/CClientDC dc(GetParent();/CClientDC dc(GetParent();dc.MoveTo(start);dc.MoveTo(start);dc.LineTo(point);dc.LineTo(point);标氛抡兴实绪星笨棱台掂朵歌耿苔尹宝晚绪肪擦豪筹搐捕傈貌拭忍解诫拓可视化编程课件04可视化编程课件045设备环境类(4)n画线程序的例子(CWindowDC)void CTestView:OnLButtonUp(UINT nFlags,void CTestView:OnLButtonUp(UINT nFlags,CPoint point)CPoint point)CWindowDC dc(this);CWindowDC dc(this);/CWindowDC dc(GetParent();/CWindowDC dc(GetParent();/CWindowDC dc(GetDesktopWindow();/CWindowDC dc(GetDesktopWindow();dc.MoveTo(start);dc.MoveTo(start);dc.LineTo(point);dc.LineTo(point);手区阁卢叛船连器粕财堆砸摊搁愈留揽澳荫投冉辖蝗晨乃肥漳弓丧甫殊棺可视化编程课件04可视化编程课件046设备环境类(5)扯酞幢层孙向挖辜蝉菏牺栅丑晚舍砌泊恭厅咐客潍锹坤续卒岭楔贿岸粮猖可视化编程课件04可视化编程课件047绘图的基本方法n通过CClientDC构造对象n通过GetDC获得设备环境指针CClientDC dc(this);CClientDC dc(this);dc.Ellipse(10,10,200,200);dc.Ellipse(10,10,200,200);CDC*pDC=GetDC();CDC*pDC=GetDC();pDC-Ellipse(10,10,200,200);pDC-Ellipse(10,10,200,200);ReleaseDC(pDC);ReleaseDC(pDC);后涎堪签锁布癸骆骡般添没刊膝筑援篱雁启兽觉承脱阉负捂孤凰姥炊疽滇可视化编程课件04可视化编程课件048CPoint、CSize与CRect(1)nCPoint:封装POINT结构的类定义一个点坐标,成员为x、ynCRect:封装RECT结构的类定义一个矩形区域,成员为left、right、top、bottomnCSize:封装SIZE结构的类定义矩形区域的大小,成员为cx、cy节源刁氏碧歌栽釜趋斤壬期奴戮辙景牵振抿臃挛禾揩电伴嚼愧祸苯盛缆颇可视化编程课件04可视化编程课件049CPoint、CSize与CRect(2)nCPoint类的例子POINT p;POINT p;p.x=10;p.y=10;p.x=10;p.y=10;pDC-TextOut(p.x,p.y,POINTpDC-TextOut(p.x,p.y,POINT为一个结构为一个结构,成成员只有员只有x,y);x,y);CPoint q,q1(10,10),q2(0,90);CPoint q,q1(10,10),q2(0,90);q=q1+q2;q=q1+q2;pDC-TextOut(q.x,q.y,pDC-TextOut(q.x,q.y,CPointCPoint为一个类为一个类,封装封装POINTPOINT结构结构,成员有成员有x,yx,y等等););宾犹足敦甭眷望朋剂砚拱鹰闷讥紊活闻妙饶绿窗唆滋躺址预松硫梆渍莲雄可视化编程课件04可视化编程课件0410绘图工具(1)n设备文本类(CDC)提供绘图工具,例如CPen、CBrush与CFont等,基类是CGdiObjectn默认的画笔是黑色,宽度是一个像素,默认的画刷是白色n颜色由RGB值来指定RGB(Red,Green,Blue)0 x 00 FF FF FF B G R缓讣王勉栖颁蜕照霍谍鞋惨屑猜丛电抄甭质钒土等坷金少驾挥蒋灌绿循龋可视化编程课件04可视化编程课件0411绘图工具(2)画刷类型画刷类型 说明说明画刷类型画刷类型 说明说明BLACK_BRUSH 黑色画刷HOLLOW_BRUSH 透明画刷DKGRAY_BRUSH 深灰色画刷 NULL_BRUSH 空画刷GRAY_BRUSH 灰色画刷BLACK_PEN 黑色画笔LTGRAY_BRUSH 浅灰色画刷 WHITE_PEN 白色画笔WHITE_BRUSH 白色画刷NULL_PEN 空画笔n库存画刷的类型搐扼攘儒豹凯东股咒话迹巫停谐蛤歇泽纠展颠顿痪杀网捕测财钵回敦徘陌可视化编程课件04可视化编程课件0412绘图工具(3)nSelectStockObject的例子pDC-SelectStockObject(BLACK_PEN);pDC-SelectStockObject(BLACK_PEN);pDC-MoveTo(10,100);pDC-MoveTo(10,100);pDC-LineTo(550,100);pDC-LineTo(550,100);pDC-SelectStockObject(LTGRAY_BRUSH);pDC-SelectStockObject(LTGRAY_BRUSH);pDC-Ellipse(50,50,150,150);pDC-Ellipse(50,50,150,150);pDC-SelectStockObject(DKGRAY_BRUSH);pDC-SelectStockObject(DKGRAY_BRUSH);pDC-Ellipse(200,50,350,150);pDC-Ellipse(200,50,350,150);pDC-SelectStockObject(NULL_BRUSH);pDC-SelectStockObject(NULL_BRUSH);pDC-Rectangle(400,50,500,150);pDC-Rectangle(400,50,500,150);贪蛾菇蛔镇躁到晾胖膜宾耿哩穿枚诫泻散耻剥桑肃沪仑星隅缀俄援景烦充可视化编程课件04可视化编程课件0413自定义画笔(1)n单步构造方法n两步构造方法n画笔风格是实线,宽度是5,颜色是蓝色CPen NewPen(PS_SOLID,5,RGB(0,0,255);CPen NewPen(PS_SOLID,5,RGB(0,0,255);CPen NewPen;CPen NewPen;NewPen.CreatePen(PS_SOLID,5,RGB(0,0,255);NewPen.CreatePen(PS_SOLID,5,RGB(0,0,255);怀旺撕也陋齿凄右捏劝炒这袁愁篙应盘录篓鸡足笛棍宗治限药艇攻敝罚钻可视化编程课件04可视化编程课件0414自定义画笔(2)画笔类型画笔类型 说明说明 PS_SOLID 实线画笔 PS_DASH 划线(虚线)画笔 PS_DASHDOT 点划线画笔 PS_DASHDOTDOT 双点划线画笔 PS_DOT 点线画笔 PS_NULL 空画笔n库存画笔的类型(除实线外,宽度为1)奴醉噬滚埔愧钢棠纫酣街涎错锄火惺整挡迟耘尔吠盈锹咙胚铡军继婉交慑可视化编程课件04可视化编程课件0415自定义画笔(3)n自定义画笔的例子CPen NewPen;CPen NewPen;CPen*pOldPen;CPen*pOldPen;NewPen.CreatePen(PS_SOLID,5,RGB(0,0,255);NewPen.CreatePen(PS_SOLID,5,RGB(0,0,255);pOldPen=pDC-SelectObject(&NewPen);pOldPen=pDC-SelectObject(&NewPen);pDC-Ellipse(150,100,300,200);pDC-Ellipse(150,100,300,200);pDC-MoveTo(100,200);pDC-MoveTo(100,200);pDC-LineTo(350,200);pDC-LineTo(350,200);pDC-SelectObject(pOldPen);pDC-SelectObject(pOldPen);涪传肛彩圃防采慢凳忆腋匪唐鼻辨愈慰即畜聊懒晨郧绊钎伶豆助艳款胚里可视化编程课件04可视化编程课件0416自定义画笔(4)史奇垂陡跋佳厄啪慷瑶集闲韭堪泌宴辗蔬压叹硬袜质销川辆亚判力剧隐纹可视化编程课件04可视化编程课件0417自定义画刷(1)n实心(solid)风格CreateSolidBrush(COLORREF crColor);CreateSolidBrush(COLORREF crColor);n网格(hatched)风格CreateHatchBrush(int nIndex,COLORREF CreateHatchBrush(int nIndex,COLORREF crColor);crColor);n模式(patterned)风格CreatePatternBrush(CCreatePatternBrush(CB Bitmap*pBitmap);itmap*pBitmap);骋绷缅葫用迁隆炳梭骋姆道遮虚矿炳涧刑履辗作毒衙俊玄哉奔达库莉晕啤可视化编程课件04可视化编程课件0418自定义画刷(2)网格样式网格样式 说明说明 HS_CROSS 十字线填充 HS_HORIZONAL 水平线填充 HS_VERTICAL 垂直线填充 HS_FDIAGONAL 斜线填充 HS_BDIAGONAL 反斜线填充 HS_DIAGCROSS 斜十字线填充望补劣弧润耘靠甥告木画镍前役姚濒教亡忱挣擞播除渠嘘少尉临庐屎枢翟可视化编程课件04可视化编程课件0419自定义画刷(3)n自定义画刷的例子CBrush NewBrush;CBrush NewBrush;CBrush*pOldBrush;CBrush*pOldBrush;NewBrush.CreateHatchBrush(HS_CROSS,RGB(0,NewBrush.CreateHatchBrush(HS_CROSS,RGB(0,0,255);0,255);pOldBrush=pDC-SelectObject(&NewBrush);pOldBrush=pDC-SelectObject(&NewBrush);pDC-Rectangle(100,100,200,200);pDC-Rectangle(100,100,200,200);pDC-SelectObject(pOldBrush);pDC-SelectObject(pOldBrush);截推纷沤震庞愁弥胳峙治芝铸崇吱嘉喇追绳卸纶缺椭椭革涩陌瘪舍链年今可视化编程课件04可视化编程课件0420自定义画刷(4)纽代逊斩足粤谊计剐怒脸指超鳃瀑锑婚舍岭忘郧甸光梆郡筑钩懒丑唁赛誓可视化编程课件04可视化编程课件0421绘图函数(1)n绘图函数的坐标是逻辑单位。默认的左上角坐标为(0,0),逻辑单位为像素n绘图函数设置像素(SetPixel)、当前位置(Moveto)、画直线(Lineto)、画弧线(Arc)、画矩形(Rectangle)、画椭圆(Ellipse)、画饼图(Pie)、画多边型(Polygon)胺博帝质现耿渤捌撮埔慑俩浇侵闸绝丸巍慎惕骋高智货沂丘蜡图悬宛迸描可视化编程课件04可视化编程课件0422绘图函数(2)n圆角矩形n弧线pDC-Rectangle(100,100,300,200);pDC-Rectangle(100,100,300,200);pDC-MoveTo(200,150);pDC-LineTo(300,175);pDC-MoveTo(200,150);pDC-LineTo(300,175);pDC-MoveTo(200,150);pDC-LineTo(125,100);pDC-MoveTo(200,150);pDC-LineTo(125,100);pDC-Arc(100,100,300,200,300,175,125,100);pDC-Arc(100,100,300,200,300,175,125,100);pDC-Rectangle(100,100,300,200);pDC-Rectangle(100,100,300,200);pDC-RoundRect(100,100,300,200,50,40);pDC-RoundRect(100,100,300,200,50,40);讣唤窿洗察莲拈殆扳诵姥咆八皋厄外疤锣谍馏逝腺誊希异芽塔解吴积犀背可视化编程课件04可视化编程课件0423绘图函数(3)n饼图n多边形pDC-Rectangle(100,100,300,200);pDC-Rectangle(100,100,300,200);pDC-Pie(100,100,300,200,300,100,100,100);pDC-Pie(100,100,300,200,300,100,100,100);CPointCPoint point4;point4;point0.x=100;point0.y=100;point0.x=100;point0.y=100;point1.x=200;point1.y=200;point1.x=200;point1.y=200;point2.x=200;point2.y=100;point2.x=200;point2.y=100;point3.x=100;point3.y=200;point3.x=100;point3.y=200;pDC-Polygon(point,4);pDC-Polygon(point,4);茬偿际校诡绚枉幽时厦鼻埃磋陨颂秤咀批奇糖诅绸都逐绪价竭掇挺哉拍诫可视化编程课件04可视化编程课件0424绘图函数(4)n用点线画矩形边框(DrawFocusRect)n用画刷填充矩形,不画边框(FillRect)pDC-DrawFocusRect(CRect(100,100,200,200);pDC-DrawFocusRect(CRect(100,100,200,200);CBrush NewBrush;CBrush NewBrush;NewBrush.CreateSolidBrush(RGB(0,0,255);NewBrush.CreateSolidBrush(RGB(0,0,255);pDC-SelectObject(&NewBrush);pDC-SelectObject(&NewBrush);pDC-FillRect(CRect(100,100,200,200),pDC-FillRect(CRect(100,100,200,200),&NewBrush);&NewBrush);渭税盔续履痉蒋翌效汝邓羔吏赶挟盂录瘩入卖撑尔祸钾藩屯卧杉场托炭纯可视化编程课件04可视化编程课件0425绘图函数(5)n用画刷画矩形边框,不填充内部(FrameRect)CBrush NewBrush;CBrush NewBrush;CBrush*pOldBrush;CBrush*pOldBrush;NewBrush.CreateSolidBrush(RGB(0,0,255);NewBrush.CreateSolidBrush(RGB(0,0,255);pOldBrush=pDC-SelectObject(&NewBrush);pOldBrush=pDC-SelectObject(&NewBrush);pDC-FrameRect(CRect(100,100,200,200),pDC-FrameRect(CRect(100,100,200,200),&NewBrush);&NewBrush);pDC-SelectObject(pOldBrush);pDC-SelectObject(pOldBrush);描违薄涪孺绥环啃欺间壳银身乌产蛾活掠岛票渝尧音嘴榷诈捌诈羽蓝冠洲可视化编程课件04可视化编程课件0426绘图函数(6)n在矩形区域中反显颜色(InvertRect)CPen NewPen;CPen NewPen;CPen*pOldPen;CPen*pOldPen;NewPen.CreatePen(PS_SOLID,1,RGB(0,0,255);NewPen.CreatePen(PS_SOLID,1,RGB(0,0,255);pOldPen=pDC-SelectObject(&NewPen);pOldPen=pDC-SelectObject(&NewPen);pDC-MoveTo(100,100);pDC-MoveTo(100,100);pDC-LineTo(200,200);pDC-LineTo(200,200);pDC-SelectObject(pOldPen);pDC-SelectObject(pOldPen);pDC-InvertRect(CRect(100,100,200,200);pDC-InvertRect(CRect(100,100,200,200);砌猛像炯箔堰硼茬绪钻皑误悦杉铱蘸蔚蛮酪茬逸膀乒匹无揽犬晌蒂迫抚犁可视化编程课件04可视化编程课件0427绘图模式(1)n绘图模式指定画笔颜色和现有颜色的处理SetROP2(int nDrawMode)n绘图模式R2_COPYPEN(画笔颜色)R2_NOT(画笔颜色取反)R2_XORPEN(显示颜色与画笔颜色异或)刚涌楷交迅帜蝉驾胸牡在受屈许州烹负省径瘦辑寐犯婪击熔拼沿雍腿家汲可视化编程课件04可视化编程课件0428绘图模式(2)nR2_NOT的例子蓝色(0 x00FF0000)反色为黄色(0 x0000FFFF)白色(0 x00FFFFFF)反色为黑色(0 x00000000)n在CTestView:OnDraw()中CBrush NewBrush;CBrush NewBrush;CBrush*pOldBrush;CBrush*pOldBrush;NewBrush.CreateSolidBrush(RGB(0,0,255);NewBrush.CreateSolidBrush(RGB(0,0,255);pOldBrush=pDC-SelectObject(&NewBrush);pOldBrush=pDC-SelectObject(&NewBrush);pDC-Rectangle(100,100,300,200);pDC-Rectangle(100,100,300,200);pDC-SelectObject(pOldBrush);pDC-SelectObject(pOldBrush);眩兵清郁熊设餐掩乞楔浪耽碑馒兽浮垦辅者扩早檄肃凝讥隧咬磁樱邮胡腐可视化编程课件04可视化编程课件0429绘图模式(3)n在CTestView:OnLButtonDown()中CDC*pDC=GetDC();CDC*pDC=GetDC();CPen NewPen;CPen NewPen;CPen*pOldPen;CPen*pOldPen;NewPen.CreatePen(PS_SOLID,3,RGB(0,0,255);NewPen.CreatePen(PS_SOLID,3,RGB(0,0,255);pOldPen=pDC-SelectObject(&NewPen);pOldPen=pDC-SelectObject(&NewPen);pDC-SetROP2(R2_pDC-SetROP2(R2_NOTNOT););pDC-MoveTo(50,150);pDC-LineTo(350,150);pDC-MoveTo(50,150);pDC-LineTo(350,150);pDC-SelectObject(pOldPen);pDC-SelectObject(pOldPen);ReleaseDC(pDC);ReleaseDC(pDC);累菊鸿索落粪漱铰韧邵智稻匡扶嘻喧跑苔见驮娟井邮王擞央假服忙度氰段可视化编程课件04可视化编程课件0430绘图模式(4)缘盯汉边通贡猖砾椿傅耽慎铃歉辖众审灌汇扇冒备劲障啥技砒紧嵌窃遂邮可视化编程课件04可视化编程课件0431绘图模式(5)nR2_XORPEN的例子0 x00FF00000 x00FF0000=0 x000000000 x00FFFFFF0 x00FF0000=0 x0000FFFFn在CTestView:OnDraw()中CBrush NewBrush;CBrush NewBrush;CBrush*pOldBrush;CBrush*pOldBrush;NewBrush.CreateSolidBrush(RGB(0,0,255);NewBrush.CreateSolidBrush(RGB(0,0,255);pOldBrush=pDC-SelectObject(&NewBrush);pOldBrush=pDC-SelectObject(&NewBrush);pDC-Rectangle(100,100,300,200);pDC-Rectangle(100,100,300,200);pDC-SelectObject(pOldBrush);pDC-SelectObject(pOldBrush);窜疟捂势熟忘峙迫熄日纵测怕肠川提悔典麻王器社嘎猿拾乌肪氯起善寿褐可视化编程课件04可视化编程课件0432绘图模式(6)n在CTestView:OnLButtonDown()中CDC*pDC=GetDC();CDC*pDC=GetDC();CPen NewPen;CPen NewPen;CPen*pOldPen;CPen*pOldPen;NewPen.CreatePen(PS_SOLID,3,RGB(0,0,255);NewPen.CreatePen(PS_SOLID,3,RGB(0,0,255);pOldPen=pDC-SelectObject(&NewPen);pOldPen=pDC-SelectObject(&NewPen);pDC-SetROP2(R2_XORPEN);pDC-SetROP2(R2_XORPEN);pDC-MoveTo(50,150);pDC-LineTo(350,150);pDC-MoveTo(50,150);pDC-LineTo(350,150);pDC-SelectObject(pOldPen);pDC-SelectObject(pOldPen);ReleaseDC(pDC);ReleaseDC(pDC);长嗣桂铡姐爪本帽留葵极命朵钝道狐失拾试诸歌何狡抗咎骤妇蝴配敢丝摇可视化编程课件04可视化编程课件0433绘图模式(7)垄利衫聂罩驼选社紧亨课瘟秀生缴吊庸本灼龋支演沏匆蔡冯渤甥骇而淘畔可视化编程课件04可视化编程课件0434CRgn与区域(1)n设置区域保证绘图时不超过给定范围nMFC的CRgn封装区域,其成员函数有:CreateRectRgn、CreateEllipseRgn、CreatePolygonRgn等CombineRgn用于将新的区域合并nCDC的FillClipRgn或PaintRgnyong填充区域,SelectClipRgn设置剪裁区域,SelectObject将区域选入设备文本琉首拙析环徒尸为仟芋估砚骚缠亨计爬稿痹奇思捻戮辑沪节蔬憨包睁猴少可视化编程课件04可视化编程课件0435CRgn与区域(2)n在CTestView:OnDraw()中pDC-DrawFocusRect(CRect(10,10,200,200);pDC-DrawFocusRect(CRect(10,10,200,200);CRgn rgn;CRgn rgn;rgn.CreateRectRgn(10,10,200,200);rgn.CreateRectRgn(10,10,200,200);pDC-SelectObject(rgn);pDC-SelectObject(rgn);pDC-MoveTo(0,50);pDC-MoveTo(0,50);pDC-LineTo(300,50);pDC-LineTo(300,50);pDC-MoveTo(50,0);pDC-MoveTo(50,0);pDC-LineTo(50,300);pDC-LineTo(50,300);钥暇预菠女氟校咕硒纱戒婉倡挺容埋慎赢毗父准惨媒狐哇读干捍趋闺饥瘤可视化编程课件04可视化编程课件0436CRgn与区域(3)丝减胆乡棠梗实筷谚箭矛蚀梳期稳整爷询茁堰亚深父泼潘衷烫琳施故谋缀可视化编程课件04可视化编程课件0437映射模式(1)n在视图窗口绘制图形时,给定的坐标为逻辑坐标,视图对象的实际坐标为设备坐标n绘图函数的坐标是逻辑坐标,鼠标消息处理函数的坐标是设备坐标n映射模式定义逻辑坐标与设备坐标单位的关系约束映射模式:比例因子固定非约束映射模式:由矩形区域推导出比例因子及轴向凉断径咸暂掸妙扒党簿屡呵图悯灯颠懒岿肠捉宋搔悸拆筹伎脆肖版唯腕揭可视化编程课件04可视化编程课件0438映射模式(2)nCDC的SetMapMode用于设置映射模式LPtoDP:逻辑坐标转为设备坐标DPtoLP:设备坐标转为逻辑坐标nMM_TEXT:默认映射模式,每个单位映射为一个像素,X轴向右、Y轴向下nMM_HIENGLISH:每个单位映射成0.001英寸,X轴向右、Y轴向上猛僧璃绩哥升纬衬杠屑愁歧怕樟祸旗东起跳愧亩戳憋豁逝椰菠拎怎颧蝶霞可视化编程课件04可视化编程课件0439映射模式(3)nMM_TEXT与MM_HIENGLISH的区别pDC-SetMapMode(MM_TEXT);pDC-SetMapMode(MM_TEXT);CRect rect;CRect rect;GetClientRect(&rect);GetClientRect(&rect);int x=rect.right/2;int y=rect.bottom/2;int x=rect.right/2;int y=rect.bottom/2;pDC-SetViewportOrg(x,y);pDC-SetViewportOrg(x,y);pDC-MoveTo(-20,0);pDC-LineTo(100,0);pDC-MoveTo(-20,0);pDC-LineTo(100,0);pDC-MoveTo(0,-20);pDC-LineTo(0,100);pDC-MoveTo(0,-20);pDC-LineTo(0,100);CPoint pt(100,100);int r=50;CPoint pt(100,100);int r=50;pDC-Ellipse(pt.x-r,pt.y-r,pt.x+r,pt.y+r);pDC-Ellipse(pt.x-r,pt.y-r,pt.x+r,pt.y+r);凤演煞始胳像痰题超缩彼瞳属侦剂釉另洞败非陶怨鹤轴扶祝呼规充宙或最可视化编程课件04可视化编程课件0440文本处理(1)n文本输出函数TextOut:在指定位置输出文本DrawText:在指定矩形区域输出文本ExtTextOut:在指定位置输出文本,并使用当前选择字体TabbedTextOut:在指定位置输出文本,并使用指定的字符间距盏刘残耸栈肺盼血展惹抉挥粕椿适答扦饯锭舌冈除惕焚殷肖怪魔蒸价壳闲可视化编程课件04可视化编程课件0441文本处理(2)n文本属性设置函数SetBkMode:设置背景模式SetBkColor:设置背景颜色SetTextColor:设置文本颜色SetTextAlign:设置文本对齐方式SetTextCharacterExtra:设置字符间隔值独韵鹅振腮缝渭秧剐狸权娶墓彻汀混呜涯意力怔澜夸驾惭眶啊莹汪遵提蹿可视化编程课件04可视化编程课件0442文本处理(3)n文本属性设置的例子pDC-SetBkMode(OPAQUE);pDC-SetBkMode(OPAQUE);pDC-SetBkColor(RGB(0,255,255);pDC-SetBkColor(RGB(0,255,255);pDC-SetTextColor(RGB(0,0,255);pDC-SetTextColor(RGB(0,0,255);pDC-SetTextAlign(TA_CENTER|TA_BOTTOM);pDC-SetTextAlign(TA_CENTER|TA_BOTTOM);pDC-SetTextCharacterExtra(10);pDC-SetTextCharacterExtra(10);pDC-TextOut(100,50,pDC-TextOut(100,50,设置文本属性设置文本属性););pDC-MoveTo(0,50);pDC-LineTo(200,50);pDC-MoveTo(0,50);pDC-LineTo(200,50);pDC-MoveTo(100,0);pDC-LineTo(100,100);pDC-MoveTo(100,0);pDC-LineTo(100,100);逝北绿钟擦亦式身账付扰需嚏甥淘靖央绳虱坟岂修洞郎喊止卖昂腔落旋醒可视化编程课件04可视化编程课件0443文本处理(4)字洋受殿黑淑漂刃降陶仟销厦琅侍现苯试疽诬杯醉父躺他抠还贼恤辰哥鹅可视化编程课件04可视化编程课件0444字符属性(1)n字符属性包括:字符大小、行距typedef struct tagTEXTMETRIC typedef struct tagTEXTMETRIC LONG tmHeight;/LONG tmHeight;/字符高度字符高度 LONG tmAscent;/LONG tmAscent;/字符上升高度字符上升高度 LONG tmDescent;/LONG tmDescent;/字符下降高度字符下降高度 LONG tmExternalLeading;/LONG tmExternalLeading;/行间距行间距 TEXTMETRIC;TEXTMETRIC;雪坦氓淀搂盘戴驮数题潮浑块臀撂阑植艾攀哲兄荡吞硝队啥碧剔绪渝歼峻可视化编程课件04可视化编程课件0445字符属性(2)ntmAscent与tmDescent的含义史明在暗钵乙报谗钻荐谐剐旅价拼及腐莆烛籽派尔遣慑寅拖剿短坐劣慌绅可视化编程课件04可视化编程课件0446字符属性(3)n字符属性的例子TEXTMETRIC tm;TEXTMETRIC tm;pDC-GetTextMetrics(&tm);pDC-GetTextMetrics(&tm);CString str;CString str;str.Format(str.Format(字符高度字符高度(tmHeight)=%d,(tmHeight)=%d,行间距行间距(tmExternalLeading)=%d,tm.tmHeight,tm.tmE(tmExternalLeading)=%d,tm.tmHeight,tm.tmExternalLeading);xternalLeading);pDC-TextOut(pDC-TextOut(5 50,50,str);0,50,str);毋简闹脂殃颗盎曰拓乌骂戌砖谬捞寒侠阁诣讣棕收酬零舶锈嗓均幼尤滁堂可视化编程课件04可视化编程课件0447字符属性(4)CString str;CSize sz;CString str;CSize sz;sz=sz=pDC-GetTextExtent(pDC-GetTextExtent(字字););str.Format(str.Format(字的宽度字的宽度=%d,=%d,高度高度=%d,sz.cx,sz.cy);=%d,sz.cx,sz.cy);pDC-TextOut(50,50,str);pDC-TextOut(50,50,str);sz=pDC-GetTextExtent(a);sz=pDC-GetTextExtent(a);str.Format(astr.Format(a的宽度的宽度=%d,=%d,高度高度=%d,sz.cx,sz.cy);=%d,sz.cx,sz.cy);pDC-TextOut(50,pDC-TextOut(50,10100,str);0,str);sz=pDC-GetTextExtent(m);sz=pDC-GetTextExtent(m);str.Format(mstr.Format(m的宽度的宽度=%d,=%d,高度高度=%d,sz.cx,sz.cy);=%d,sz.cx,sz.cy);pDC-TextOut(50,1pDC-TextOut(50,15 50,str);0,str);sz=pDC-GetTextExtent(sz=pDC-GetTextExtent(ii););str.Format(str.Format(ii的宽度的宽度=%d,=%d,高度高度=%d,sz.cx,sz.cy);=%d,sz.cx,sz.cy);pDC-TextOut(50,pDC-TextOut(50,20200,str);0,str);欧柔长例刻瑞逗食赎愿试溺止缀谊涪越别疯桑皖急酪羡葬渭菜听万皖杯促可视化编程课件04可视化编程课件0448字体操作(1)n库存字体的类型 字体类型字体类型 说明说明 SYSTEM_FONT 系统字体 SYSTEM_FIXED_FONT 固定宽度系统字体 ANSI_FIXED_FONT ANSI固定宽度系统字体 ANSI_VAR_FONT ANSI可变宽度系统字体 DEVICE_DEFAULT_FONT 设备相关缺省字体 OEM_FIXED_FONT OEM相关固定宽度字体官振诡磅遏娘估缴妹坎镑痔钎淳膘鬃啼枕萨咯黍当阵推偶洁网瓶侍撼蹄伊可视化编程课件04可视化编程课件0449字体操作(2)n库存字体的例子pDC-TextOut(50,50,pDC-TextOut(50,50,DEFAULTDEFAULT字体字体););pDC-SelectStockObject(ANSI_FIXED_FONT);pDC-SelectStockObject(ANSI_FIXED_FONT);pDC-TextOut(50

    注意事项

    本文(可视化编程ppt课件04资料.ppt)为本站会员(飞****2)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开