如何将CRichEdit控件背景设置为透明?

tanwei1002 2009-02-07 02:55:42
谢谢
...全文
224 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
huaguocsdn 2009-02-11
  • 打赏
  • 举报
回复
学习学习,good。
路人乙2019 2009-02-10
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 tanwei1002 的回复:]
已经解决
找到了2种方法

谢谢大家
[/Quote]哪两种方法,共享一下吧。
tanwei1002 2009-02-10
  • 打赏
  • 举报
回复
已经解决
找到了2种方法

谢谢大家
tanwei1002 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 allenhiman 的回复:]
利用普通的透明,其实就是更改richiedit的背景色为窗口北京色,不是真正的透明。要想实现很好的效果就得自己重载richedit.比如北京是图片。上述透明方案无效。。。 别怕麻烦 go...
[/Quote]


看来只能重载了,。。。
allenhiman 2009-02-09
  • 打赏
  • 举报
回复
利用普通的透明,其实就是更改richiedit的背景色为窗口北京色,不是真正的透明。要想实现很好的效果就得自己重载richedit.比如北京是图片。上述透明方案无效。。。 别怕麻烦 go...
tanwei1002 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fishion 的回复:]
long style = ::GetWindowLong(GetDlgItem(IDC_RICHEDIT)->GetSafeHwnd(), GWL_STYLE);
style &= WS_EX_TRANSPARENT;
::SetWindowLong(GetDlgItem(IDC_RICHEDIT)->GetSafeHwnd(), GWL_STYLE, style);
[/Quote]

这样是透明了 可是里面的文字却显示不出来了
tanwei1002 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hustfenge 的回复:]
右键属性中extended styles 里面有transparent 这个属性。
[/Quote]、
点这没用
tanwei1002 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 liuzxchina 的回复:]
在OnCtlColor里面进行处理

C/C++ code
HBRUSH CPenWidthsDlg::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 m…
[/Quote]


是RichEdit控件,不是Edit啊。。。。大哥
lihan6415151528 2009-02-07
  • 打赏
  • 举报
回复
不谢
hustfenge 2009-02-07
  • 打赏
  • 举报
回复
右键属性中extended styles 里面有transparent 这个属性。
liuzxchina 2009-02-07
  • 打赏
  • 举报
回复
在OnCtlColor里面进行处理

HBRUSH CPenWidthsDlg::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_EDIT)
{
// 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
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}

return hbr;
}

fishion 2009-02-07
  • 打赏
  • 举报
回复
long style = ::GetWindowLong(GetDlgItem(IDC_RICHEDIT)->GetSafeHwnd(), GWL_STYLE);
style &= WS_EX_TRANSPARENT;
::SetWindowLong(GetDlgItem(IDC_RICHEDIT)->GetSafeHwnd(), GWL_STYLE, style);

15,979

社区成员

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

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