如何使static控件透明?

linfeng1216 2003-03-11 11:57:12
我设置了对话框的背景色,在上面放的static控件文字下就出现了背景色,如何使static控件透明?
...全文
50 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangs 2003-03-12
  • 打赏
  • 举报
回复
处理WM_CTLCOLOR消息
pDC->SetBkMode(TRANSPARENT);
曾经的猎狐 2003-03-12
  • 打赏
  • 举报
回复
响应WM_CTLCOLOR消息

然后在OnCtlColor()函数内判断
HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we're trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// Are we painting the IDC_MYSTATIC control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
// Set the text color to red
pDC->SetTextColor(RGB(255, 0, 0));

// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);

// Return handle to our CBrush object
hbr = m_brush;
}

return hbr;
}

15,979

社区成员

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

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