请教:CDC类绘图一个按钮?

fsqcling 2003-05-27 11:05:17
先定义的一个矩形,当鼠标进入这个矩形范围时,能显示弹起效果,
当鼠标按下时,能显示按下效果,当鼠标弹起时,能恢复正常效果.

...全文
43 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tue 2003-05-27
  • 打赏
  • 举报
回复
用CDC绘制很简单,
void Draw3dRect( LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight );
void Draw3dRect( int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight );
3D效果是由下面两个颜色起作用:COLORREF clrTopLeft, COLORREF clrBottomRight


mlin2000 2003-05-27
  • 打赏
  • 举报
回复
继承CButton类
class CMyButton : public CButton
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
//重新绘制按钮
}

void CMyButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
//判断按钮为自绘按钮

CButton::PreSubclassWindow();
}
cyczl666 2003-05-27
  • 打赏
  • 举报
回复
利用MouseMove()消息,判断当鼠标位于矩形内时,显示弹起效果,否则显示正常效果。
利用MouseDown()消息,判断当鼠标单击且位于矩形内时,显示按下效果。
利用MouseUp()消息,判断当鼠标放开且位于矩形内时,响应相应的函数。

fsqcling 2003-05-27
  • 打赏
  • 举报
回复
大侠们谢了!
还有得到设备环境CDC (为对话框客户区)
用Attach();HDC参数怎么填!
aoosang 2003-05-27
  • 打赏
  • 举报
回复
不错

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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