Win32 Windows编程 十
一 Windows画图
1 图形绘制
1.1 图形绘制的方式
获取到画图的句柄,设备描写叙述符(DC)。使用对应的画图API。在设备上绘制图形
1.2 颜色
RGB,每种颜色8位,共24位颜色
32位颜色:颜色数量24为颜色,多出的8位表示灰度。
16位:颜色数量是2的16次方。
Win32下。颜色的定义使用 COLORREF。RGB的宏定义颜色
COLORREF nColor = RGB( 0, 0, 0 ); 黑色
COLORREF nColor = RGB( 255, 255, 255 ); 白色
COLORREF nColor = RGB( 255, 255, 255 ); 红色
从一个颜色值中获取RGB三色:
int nRed = GetRValue( DWord rgb )
int nGreen = GetGValue( DWord rgb )
int nBlue = GetBVakue( DWord rgb )
1.3 点的绘制和获取
绘制: SetPixel
COLORREF SetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos, // y-coordinate of pixel
COLORREF crColor // 颜色值
);
获取: GetPixel
COLORREF GetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
1.4 直线的绘制
MoveToEx移动当前点到指定位置
LineTo 从当前点绘制之前到指定位置
1.5 弧的绘制
Arc和AngleArc提供不同的绘制弧的方式
BOOL AngleArc(
HDC hdc, // handle to device context
int X, // x-coordinate of circle's center 圆心x坐标
int Y, // y-coordinate of circle's center 圆心y坐标
DWORD dwRadius, // circle's radius 园的半径
FLOAT eStartAngle, // arc's start angle 開始角度
FLOAT eSweepAngle // arc's sweep angle 夹角
);
圆弧的分割方式
int SetArcDirection(
HDC hdc, // handle to device context
int ArcDirection // new arc direction
);
BOOL Arc(
HDC hdc, // handle to device context
int nLeftRect, // x-coord of rectangle's upper-left corner
int nTopRect, // y-coord of rectangle's upper-left corner
int nRightRect, // x-coord of rectangle's lower-right corner
int nBottomRect, // y-coord of rectangle's lower-right corner 外切矩形的坐标
int nXStartArc, // x-coord of first radial ending point
int nYStartArc, // y-coord of first radial ending point
int nXEndArc, // x-coord of second radial ending point
int nYEndArc // y-coord of second radial ending point
);
1.6 折线
BOOL Polyline(
HDC hdc, // handle to device context
CONST POINT *lppt, // array of endpoints
int cPoints // number of points in array
);
BOOL PolylineTo(
HDC hdc, // handle to device context
CONST POINT *lppt, // array of points
DWORD cCount // number of points in array
); 与PolyLine类似, 在绘制PolyLine前。从当前点使用LineTo绘制直线到Polyline的第一个顶点
BOOL PolyPolyline(
HDC hdc, // handle to device context
CONST POINT *lppt, // array of points 全部点的数组
CONST DWORD *lpdwPolyPoints, // array of values 每组点的数量
DWORD cCount // number of entries in values array 分组的数量
);
1.7 Bizer曲线
BOOL PolyBezier(
HDC hdc, // handle to device context
CONST POINT* lppt, // endpoints and control points 点数组
DWORD cPoints // count of endpoints and control points 点的数量
);
1.8 圆角矩形
BOOL RoundRect(
HDC hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
int nWidth, // width of ellipse 生成圆角的椭圆的宽度
int nHeight // height of ellipse 生成圆角的椭圆的高度
);
1.9 矩形
BOOL Rectangle(
HDC hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect // y-coord of lower-right corner of rectangle
);
1.10 椭圆
BOOL Ellipse(
HDC hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect // y-coord of lower-right corner of rectangle
);
1.11 pie饼
BOOL Pie(
HDC hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
int nXRadial1, // x-coord of first radial's endpoint
int nYRadial1, // y-coord of first radial's endpoint
int nXRadial2, // x-coord of second radial's endpoint
int nYRadial2 // y-coord of second radial's endpoint
);
1.12 弦
BOOL Chord(
HDC hdc, // handle to DC
int nLeftRect, // x-coord of upper-left corner of rectangle
int nTopRect, // y-coord of upper-left corner of rectangle
int nRightRect, // x-coord of lower-right corner of rectangle
int nBottomRect, // y-coord of lower-right corner of rectangle
int nXRadial1, // x-coord of first radial's endpoint
int nYRadial1, // y-coord of first radial's endpoint
int nXRadial2, // x-coord of second radial's endpoint
int nYRadial2 // y-coord of second radial's endpoint
);
1.13 多变形
BOOL Polygon(
HDC hdc, // handle to DC
CONST POINT *lpPoints, // polygon vertices
int nCount // count of polygon vertices
);
2 GDI画图对象 - 画笔
2.1 画笔的作用
能够控制线条的颜色、样式、宽度
2.2 画笔的使用
创建画笔
CreatePen
置成当前DC能够使用的画笔
SelectObject
绘制图形
从当前DC中取出画笔
SelectObject
销毁画笔
DeleteObject
3 GDI画图对象 - 画刷
3.1 画刷的作用
填充封闭图形,包含样式 颜色
3.2 画刷的使用
创建画刷
CreateSilidBrush
CreateHatchBrush
置成当前DC能够使用的画刷
SelectObject
绘制图形
取出画刷
SelectObject
销毁画刷
DeleteObject
Win32 Windows编程 十的更多相关文章
- Win32 Windows编程 十二
一.对话框 1.对话框的分类 2.对话框的基本使用方式 3.对话框资源 4.有模式对话框的使用 5. 无模式对话框的使用 5.1 加入对话框资源 5.2 定义窗体处理函数 BOOL CALLBACK ...
- Win32 Windows编程 九
资源的使用 1 资源文件 图标 光标 字符串 菜单 加速键 对话框资源位图等等 资源脚本文件 - 扩展名为RC文件 定义了资源和相关文件等信息 资源编译器 - RC.exe 2 图标资源 ICON ...
- Win32 Windows编程 七
定时器消息 1. WM_TIMER 依照定时器设置的时间段,自己主动向窗体发送一个定时器消息WM_TIMER.优先级比較低 定时器精度比較低.毫秒级别.消息产生时间也精度比較低 2 .消息和函数 WM ...
- 【Windows编程】系列第十篇:文本插入符
大家知道,在使用微软的编程环境创建工程时会让你选择是控制台模式还是Windows应用程序.如果选择控制台的console模式,就会在运行时出现一个黑洞洞的字符模式窗口,里面就有等待输入一闪一闪的插入符 ...
- 【Windows编程】系列第五篇:GDI图形绘制
上两篇我们学习了文本字符输出以及Unicode编写程序,知道如何用常见Win32输出文本字符串,这一篇我们来学习Windows编程中另一个非常重要的部分GDI图形绘图.Windows的GDI函数包含数 ...
- 【Windows编程】系列第六篇:创建Toolbar与Statusbar
上一篇我们学习了解了如何使用Windows GDI画图,该应用程序都是光光的静态窗口,我们使用Windows应用程序,但凡稍微复杂一点的程序都会有工具栏和状态栏,工具栏主要用于一些快捷功能按钮.比如典 ...
- 【Windows编程】系列第八篇:通用对话框
上一篇我们学习了菜单的基本编程,本篇来了解一下通用对话框的使用.Windows系统之所以是目前最流行的桌面系统,也是因为Windows有一套标准化,统一友好的交互界面,比如菜单.工具栏.状态栏以及各个 ...
- 【Windows编程】系列第九篇:剪贴板使用
上一篇我们学习了常见的通用对话框,本篇来了解剪贴板的使用,它常用于复制粘贴功能. 剪贴板是Windows最早就加入的功能,由于该功能非常实用,我们几乎每天都会使用到.通过剪贴板,我们就可以将数据从一个 ...
- 【Windows编程】系列第三篇:文本字符输出
上一篇我们展示了如何使用Windows SDK创建基本控件,本篇来讨论如何输出文本字符. 在使用Win32编程时,我们常常要输出文本到窗口上,Windows所有的文本字符或者图形输出都是通过图形设备接 ...
随机推荐
- Spring3表达式语言(SpEL)学习笔记
最新地址请访问:http://leeyee.github.io/blog/2011/06/19/spring-expression-language Spring Excpression Langua ...
- 北京出dell s2740显示器 1900 - V2EX
水木社区归档站 北京出dell s2740显示器 1900 - V2EX 北京出dell s2740显示器 1900 By kekex · 6 小时 6 分钟前 · 188 次点击 购于今年4月份 镜 ...
- UVALive 2519 Radar Installation 雷达扫描 区间选点问题
题意:在坐标轴中给出n个岛屿的坐标,以及雷达的扫描距离,要求在y=0线上放尽量少的雷达能够覆盖全部岛屿. 很明显的区间选点问题. 代码: /* * Author: illuz <iilluzen ...
- .net面试题大全(有答案)
在网上找来的,希望对大家有所帮助. 1 (1)面向对象的语言具有__继承性_性._封装性_性._多态性 性. (2)能用foreach遍历访问的对象需要实现 _ IEnumerable 接口或 ...
- Linear Regression(线性回归)(二)—正规方程(normal equations)
(整理自AndrewNG的课件,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 在上篇博客中,我们提出了线性回归的概念,给出了一种使代价函数最小的 ...
- poj3080Blue Jeans(在m个串中找到这m个串的 最长连续公共子序列)
Description The Genographic Project is a research partnership between IBM and The National Geographi ...
- 好多NFS的文章
http://www.cnblogs.com/lidabo/category/587288.html http://www.cnblogs.com/lidabo/p/4380555.html
- 我们究竟什么时候可以使用Ehcache缓存(转)
一.Ehcache是什么 EhCache是Hibernate的二级缓存技术之一,可以把查询出来的数据存储在内存或者磁盘,节省下次同样查询语句再次查询数据库,大幅减轻数据库压力. 二.Ehcache的使 ...
- ALV双击单元格事件处理
*激发双击事件 FORM f_alv_user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. "先引 ...
- java jquery 函数多參数传递
业务需求: 名次 伙伴 业绩 签单 面谈 每日目标 1 文彬 5100 6 10 查看目标 2 马红月 4550 4 6 查看目标 3 王刚 4100 3 9 查看目标 4 郭亚凯 3450 4 ...