热情的朋友们,能否给一份画矩形的绘图函数(能填充颜色)的源程序

99jiujiu 2000-02-10 07:25:00
99jiujiu@netease.com
...全文
241 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yb 2000-02-12
  • 打赏
  • 举报
回复
你不是用VC的吗?
CDC是MFC的一个专用于绘图的类,它基于Windows的Device context(关联设备),封
装了许多绘图用WIndows API,还提供了一些比较复杂的绘图方法,如画B样曲线等。
在MFC的窗口中,你可以用GetDC等有关DC的函数取得窗口关联的CDC对象,然后就可以
使用CDC提供的功能强大的(对一般应用而言^_^)绘图方法了。
有一点要注意的是,CDC的使用有一定的规则,你可以参考一下MSDN中的说明,而且
MSDN中有许多有关的例子可以看一下。
如果你不用MFC的话,就只有用Windows API了。首先你要取得你的窗口句柄hWnd,然
后用GetDC或GetDCEx取得关联设备hDC,就可以用Rectangle来画矩形了。
颜色的填充只需要改变画刷的颜色就可以了。
99jiujiu 2000-02-11
  • 打赏
  • 举报
回复
不好意思,CDC是什么?谢谢各位朋友的关心
yb 2000-02-11
  • 打赏
  • 举报
回复
Why don't you use CDC?
aborigine 2000-02-11
  • 打赏
  • 举报
回复
你是要源程序? 去查一下计算机图形学方面的书.
通常先用Bresenham算法实现画直线函数,
对矩形的填充还是很简单的吧.
tonyhan 2000-02-11
  • 打赏
  • 举报
回复
利用上面的函数,改变画刷颜色就可以了.
kxy 2000-02-10
  • 打赏
  • 举报
回复
window API的函数 Rectangle

The Rectangle function draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush.

BOOL Rectangle(

HDC hdc, // handle of device context
int nLeftRect, // x-coord. of bounding rectangle's upper-left corner
int nTopRect, // y-coord. of bounding rectangle's upper-left corner
int nRightRect, // x-coord. of bounding rectangle's lower-right corner
int nBottomRect // y-coord. of bounding rectangle's lower-right corner
);


Parameters

hdc

Identifies the device context.

nLeftRect

Specifies the logical x-coordinate of the upper-left corner of the rectangle.

nTopRect

Specifies the logical y-coordinate of the upper-left corner of the rectangle.

nRightRect

Specifies the logical x-coordinate of the lower-right corner of the rectangle.

nBottomRect

Specifies the logical y-coordinate of the lower-right corner of the rectangle.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The current position is neither used nor updated by Rectangle.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧