对话框中有CSTATIC控件上填充颜色,但为何显不出来呢。

yellowwolf 2003-10-17 12:59:14
void CObitData::Surface()
{
CRect rect, CaptionRect;
GetClientRect(&CaptionRect);
GetDlgItem(IDC_STATICTN)->GetWindowRect(&rect);
this->ScreenToClient(&rect);
CaptionRect.right = rect.left - 5;
CaptionRect.left = 0;

// 绘制标题栏
CClientDC dc(this);
dc.FillSolidRect(&CaptionRect, RGB(20, 5, 186)); // 可以显示的

rect.left += 2;
rect.top += 2;
rect.right -= 2;
rect.bottom -= 2;

CString str;
str.Format("%d %d ", rect.top, rect.left);
//AfxMessageBox(str); 要这句去会显示

dc.FillSolidRect(&rect, RGB(245, 15, 16)); // 显示不出来。
}
AfxMessageBox(str); 有这句就可以, 好像是没有刷新的原由,
应该怎么做啊?这个函数放在了ONPAINT里面
...全文
74 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
devidzdw32 2003-10-21
  • 打赏
  • 举报
回复
把CSTATIC控件的属性把visible属性去掉。
kongyunzhongque 2003-10-20
  • 打赏
  • 举报
回复
如果要给控件填充颜色,最好映射WM_CTLCOLOR,这样一显示已经有了:
if(pWnd->GetDlgCtrlID() ==IDC_STATICTN)
{

//CBrush brush;/* in .h*/
//brush.CreateSolidBrush(RGB(245, 15, 16));/* in InitDialog */
hbr =brush;
}

19,468

社区成员

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

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