我设置背景色和前景色(前景色是文本)以后,又设置背景色透明,结果是背景色和前景色设置正确,但是前景文本背后有个小方框的颜色是背景色的初始默认颜色而不是新改的背景色~~~我是做的activex控件~~,代码,图片如下
void CClock2Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);
CBrush brush(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds,&brush);
//pdc->SetBkColor(TRANSPARENT);
pdc->SetTextColor(TranslateColor(GetForeColor()));
CTime time=CTime::GetCurrentTime();
if(0==time.GetSecond())
{
FireNewMinute();
}
CString str=time.Format("%H:%M:%S");
pdc->TextOut(0,0,str);
}
void CClock2Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);
CBrush brush(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds,&brush);
//pdc->SetBkColor(TRANSPARENT);
pdc->SetTextColor(TranslateColor(GetForeColor()));
CTime time=CTime::GetCurrentTime();
if(0==time.GetSecond())
{
FireNewMinute();
}
CString str=time.Format("%H:%M:%S");
pdc->TextOut(0,0,str);
}
解决方案 »
- windows画图析中的橡皮擦和铅笔功能要怎么实现
- 右键菜单无法正常关闭
- 今天做了一件我梦寐以求的事情
- 各位高人帮帮忙,关于位操作的问题,问题比较长,进来看看吧!
- 特急:如何在对话框的成员函数中重绘单文档视图的Ondraw???
- 想学VC的DLL编程,求相关学习资料谢谢!
- 发送什么消息达到的效果跟拖。。。。。。。。。。。
- 菜鸟倒腾炫彩界面库添加头文件和lib后仍提示“error LNK2019: 无法解析的外部符号”错误
- 怎么用vc对excel单元格的内容进行加密
- 用GetFocus()==(CWnd*)GetDlgItem(nID)来判断nID是否拥有输入焦点,为什么不行?
- 高分求:设计一个程序,验证一个表达式是不是命题公式。
- 请教大家一个子线程accept的问题
改为pdc->SetBkMode(TRANSPARENT);就没问题了,文字的小方框背景色就成了background的颜色了。不会像用 pdc->SetBkColor(TRANSPARENT); 时文字的小方框背景色是黑的了
SetBKMode!
不会像用 pdc->SetBkColor(TRANSPARENT);这个设置背景颜色啊,能直接把TRANSPARENT当参数?当然编译是没错的.....
用RGB()宏!
CBrush brush(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds,&brush);
//pdc->SetBkColor(TRANSPARENT); // TRANSPARENT不是颜色来的,#define TRANSPARENT 1
// 这样会变成RGB为1的颜色了// 改为pdc->SetBkMode(TRANSPARENT); 这样才是透明的
// 或者改为pdc->SetBkColor(TranslateColor(GetBackColor())); 将文字背景改为你的刷子的颜色也可以setbkmode和setbkcolcor在具体使用时的差别是什么,很明显看名称都不一样吧The SetBkMode function sets the background mix mode of the specified device context. The background mix mode is used with text, hatched brushes, and pen styles that are not solid lines.The SetBkColor function sets the current background color to the specified color value, or to the nearest physical color if the device cannot represent the specified color value.