从onctlcolor返回空心笔刷 [英] returning a hollow brush from onctlcolor
问题描述
我有一个使用CFormView的MDI项目.我在窗体中显示一个位图,将CStatic控件放在顶部.我重写OnCtlColor以便为控件使用空心笔刷,以便位图通过控件的''矩形显示,并且文本显示在位图的顶部.由于这里的详细描述时间太长,我将控件移到了CWnd派生类(CMainFrame中著名的CMDIClientWnd子类)中.但是,现在CStatic控件的背景不是位图,而是应用程序下的监视器上发生的任何事情.任何人都知道为什么,如何使位图再次成为控件的背景?谢谢.
I have an MDI project, using CFormView. I display a bitmap in the form, put CStatic controls on top. I override OnCtlColor to use a hollow brush for the controls so that the bitmap shows through the controls'' rectangle and the text is shown on top of the bitmap. For reasons too long to detail here, I moved the controls to a CWnd derived class (the famous CMDIClientWnd subclassed in CMainFrame). However, now the backgrounds of the CStatic controls are not the bitmap but whatever happened to be on the monitor under the application. Anyone know why, and how I can make the bitmap be the background of the controls again? Thanks.
推荐答案
我从没做过,但是值得研究的一件事可能就是看看SetLayeredWindowAttributes
是否可以为您完成这项工作.您首先需要在控件上调用SetWindowLong
来打开WS_EX_LAYERED
标志.这应该使窗口透明,以便其下面的内容得以显示.
I''ve never done this but one thing worth investigating might be to see ifSetLayeredWindowAttributes
can do the job for you. You''d first need to callSetWindowLong
on your controls to turn theWS_EX_LAYERED
flag on though. This should make the window transparent so that stuff underneath it shows through.
我添加了这两个调用,不幸的是它没有帮助.但是谢谢你的想法.
I added those 2 calls, unfortunately it didn''t help. But thanks for the ideas.
这篇关于从onctlcolor返回空心笔刷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!