OO_Win编程(10_4).pptVIP

  • 0
  • 0
  • 约1.31千字
  • 约 32页
  • 2017-04-27 发布于四川
  • 举报
OO_Win编程(10_4)

第四讲 Windows编程基础;4.1 Windows 软件结构;消息驱动体系;应用程序框架 程序开发过程;源程序结构;WinMain 的程序结构;窗口的登记、创建与显示;消息循环;例4-1:窗口函数;4.2 MFC程序设计引论;Windows系统的分析;MFC设计思想:提供程序基本框架;AppWizard 程序设计;例4-2:视窗消息映射的生成;例4-3:消息响应的编制;消息响应;使用 OO 方法的好处:;练习题(4-1);应用例4-4:绘图程序的开发;数据分析与对象确认;图元对象模型;各种图元类的实现策略;#include afx.h #include afxcoll.h class Geometry : public CObject { // 图元基类 public: virtual void Offset( int cx, int cy ) = 0; // 位移 virtual void Draw( CDC *pdc ) = 0; // 绘图 }; class Point : public Geometry { // 点图元类 public: int xVal, yVal; // 点坐标 Point( int x, int y ) { // 构造 xVal = x; yVal = y; } void Offset( int cx, int cy ) { // 位移 xVal += cx; yVal += cy; } void Draw( CDC *pdc ) { // 绘图 pdc-g.SetPixel( xVal, y.Val, RGB(0,0,0) ); } };图形类;class LineString : public Graph { public: // 线对象包含若干点对象指针 void Draw( CDC *pdc ) { // 线的绘制 if( GetSize( ) 1 ) return; Point *pt = GetAt(0); // 第一个点 pdc-MoveTo( pt-xVal, pt-yVal ); for( int i=1; iGetSize( ); i++ ) { pt = GetAt( i ); // 从第i-1点划到第i点 pdc-LineTo( pt-xVal, pt-yVal ); } } } class Surface : public LineString { public: // 面对象包含线对象 void Draw( CDC *pdc ) { // 面的绘制 LineString::Draw( pdc ); // 绘制边线 … // 可以扩充填色功能 } };文档类和 视窗类;图形的输出;鼠标点击的响应;鼠标双击 的响应(1/2);鼠标双击的响应(2/2);设计方法的小结;练习题(4-2)

文档评论(0)

1亿VIP精品文档

相关文档