问题描述
我试图创建一个在绘制32位位图时实现每像素alpha混合的控件.
I am trying to create a control that implements the per-pixel alpha blend while painting a 32-bit bitmap.
我扩展了CWnd并在资源编辑器中使用静态控件.我设法正确绘制了Alpha通道,但静态控件仍保持绘制灰色背景.
I extended a CWnd and use static control in the resource editor. I managed to paint the alpha channel correctly but still the static control keep painting the gray background.
我重写了OnEraseBkgnd以防止控件绘制背景,但是它没有用.我终于通过使用WS_EX_TRANSPARENT做到了这一点.
I overwrote the OnEraseBkgnd to prevent the control from painting the background but it didn't worked. I finally managed to do it by using WS_EX_TRANSPARENT.
我现在的问题是我的控件放置在其他控件之上.第一次绘制对话框时,所有功能都可以正常工作...但是,如果我单击父"控件(即控件下方的控件),则该控件不会收到WM_PAINT消息.所以它不再画了.
My problem now is that my control is placed over other control. The first time the dialog is painted all works fine...but if I click over the "parent" control (ie the one beneath my control) my control doesn't received the WM_PAINT message. So it is not painted anymore.
如果我将应用最小化并再次最大化,则控件将再次绘制.
If I minimize the aplication and maximized it again the controls are painted again.
请,有人可以提示吗?我为这种控制而疯狂!!!
Please, can anybody give a hint? I am getting crazy with this control!!!
谢谢.
推荐答案
我希望,如果您同时处理 WM_ERASEBKGND 和 WM_PAINT 消息,则应该涵盖了所有绘画选项,而不必诉诸 WS_EX_TRANSPARENT 样式.
I would have though that if you are processing both the WM_ERASEBKGND and the WM_PAINT messages then you should have cover all the painting options, without having to resort to using the WS_EX_TRANSPARENT style.
您确定您的代码没有将这些消息传递给默认处理吗?
Are you sure your code is not passing these messages on to the default processing?
另一种选择可能是子类,以确保静态代码是处理这两条消息的唯一代码.
One other option might be to subclass the static control, just to make sure your code is the only one handling these two messages.
这篇关于WS_EX_TRANSPARENT样式的静态控件未重绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!