用vc++6.0如何实现画点、画线、画圆,望给个代码。
答案:1 悬赏:10
解决时间 2021-01-25 11:08
- 提问者网友:低吟詩仙的傷
- 2021-01-24 20:41
用vc++6.0如何实现画点、画线、画圆,望给个代码。
最佳答案
- 二级知识专家网友:孤独的牧羊人
- 2021-01-24 22:12
以下方法可在MFC和控制台中都可以实现:
1.HDC hdc = GetDC(HWND hWnd);获得设备上下文的客户区一个指定的窗口或整个屏幕
eg:如果是在窗口类中可以:
HDC hdc = GetDC(this->m_hWnd);
2.在窗口区画点。
SetPixel(
hdc,
x,// 横坐标
y ,// 纵坐标
RGB(100,100,100));//点的颜色。
3. 画线
MoveToEx(
HDC hdc,
int X,// 横坐标
int Y,// 纵坐标
LPPOINT lpPoint //保存先前的点的位置,在这里你可以直接写NULL.
)
LineTo(
HDC hdc,// device context handle
int nXEnd,// x-coordinate of line's ending point
int nYEnd // y-coordinate of line's ending point
);
4.画圆
函数:
Ellipse(
HDC hdc,// handle to 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
);
eg:Ellipse(hdc,0,0,100,100);
1.HDC hdc = GetDC(HWND hWnd);获得设备上下文的客户区一个指定的窗口或整个屏幕
eg:如果是在窗口类中可以:
HDC hdc = GetDC(this->m_hWnd);
2.在窗口区画点。
SetPixel(
hdc,
x,// 横坐标
y ,// 纵坐标
RGB(100,100,100));//点的颜色。
3. 画线
MoveToEx(
HDC hdc,
int X,// 横坐标
int Y,// 纵坐标
LPPOINT lpPoint //保存先前的点的位置,在这里你可以直接写NULL.
)
LineTo(
HDC hdc,// device context handle
int nXEnd,// x-coordinate of line's ending point
int nYEnd // y-coordinate of line's ending point
);
4.画圆
函数:
Ellipse(
HDC hdc,// handle to 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
);
eg:Ellipse(hdc,0,0,100,100);
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |