怎样在自画菜单中绘制渐变的颜色

woodwmh 2002-03-12 06:19:55
怎样在自画菜单中绘制渐变的颜色
...全文
36 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Flysnow 2002-03-12
  • 打赏
  • 举报
回复
我给的这个函数就是画背景的哦DrawGradRect

自己响应消息就可以了
lanzhengpeng2 2002-03-12
  • 打赏
  • 举报
回复
使用新的Paltform SDK吧,里面有这样的类,称为GDI+的东西
woodwmh 2002-03-12
  • 打赏
  • 举报
回复
我要鼠标放到某个条目时,这条目变成渐变色,要怎样做??
谢谢
Flysnow 2002-03-12
  • 打赏
  • 举报
回复
void CMenu::DrawGradRect(CDC *pDC, CRect rect, COLORREF cr1,
COLORREF cr2, BOOL bHor)
{
int r1 = GetRValue(cr1);
int g1 = GetGValue(cr1);
int b1 = GetBValue(cr1);

int r2 = GetRValue(cr2);
int g2 = GetGValue(cr2);
int b2 = GetBValue(cr2);

if(bHor)
{
float dr = ((float)(r2 - r1))/(float)(rect.Width());
float dg = ((float)(g2 - g1))/(float)(rect.Width());
float db = ((float)(b2 - b1))/(float)(rect.Width());

for(int i = rect.left; i < rect.right; i ++)
{
int r = r1 + (int)(dr*((float)(i - rect.left)));
int g = g1 + (int)(dg*((float)(i - rect.left)));
int b = b1 + (int)(db*((float)(i - rect.left)));
CPen pen(PS_SOLID, 1, RGB(r, g, b));
CPen *old = pDC->SelectObject(&pen);
pDC->MoveTo(i, rect.top);
pDC->LineTo(i, rect.bottom);
pDC->SelectObject(old);
}
}
else
{
float dr = ((float)(r2 - r1))/(float)(rect.Height());
float dg = ((float)(g2 - g1))/(float)(rect.Height());
float db = ((float)(b2 - b1))/(float)(rect.Height());

for(int i = rect.top; i < rect.bottom; i ++)
{
int r = r1 + (int)(dr*((float)(i - rect.top)));
int g = g1 + (int)(dg*((float)(i - rect.top)));
int b = b1 + (int)(db*((float)(i - rect.top)));
CPen pen(PS_SOLID, 1, RGB(r, g, b));
CPen *old = pDC->SelectObject(&pen);
pDC->MoveTo(rect.left, i);
pDC->LineTo(rect.right, i);
pDC->SelectObject(old);
}
}
}
2ndboy 2002-03-12
  • 打赏
  • 举报
回复
好象有个API,记不清了,查查再回复
woodwmh 2002-03-12
  • 打赏
  • 举报
回复
高分求救!!快来抢

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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