如何在MFC中的透明窗口上绘画? [英] How can I paint on a transparent window in MFC?

查看:134
本文介绍了如何在MFC中的透明窗口上绘画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用"WS_EX_TRANSPARENT"样式使窗口透明.确实有效.

I can use the "WS_EX_TRANSPARENT" style to make a window transparent. That does work.

但是当我尝试在透明窗口上绘画时,会出现问题.虽然必须擦除窗口的背景以完成绘画工作,但擦除窗口的背景却是一个问题,因为它将使透明窗口再次变得不透明并且显示将闪烁

But when I try to paint on the transparent window, a problem occurs. While it''s necessary to erase the background of the window to do a good job of painting, the erasure of the window''s background turn out to be a problem since it will make the transparent window opaque again and the display will flicker.

我试图通过仅返回TRUE来覆盖OnEraseBkgnd()函数,并使用null_brush自己擦除窗口的背景(在我的情况下是对话框窗口),但是没有用.因此,我想知道如何在保持始终透明绘制图形的窗口的同时很好地进行绘制?我希望有人能帮助我!非常感谢!

I''ve tried to override the OnEraseBkgnd() function by just returning TRUE and use a null_brush to erase the background of the window myself (a dialog window in my case), but it didn''t work. Therefore, I want to know how can I do a good job of painting while keeping the window on which the graphic is painted transparent all the time? I''m hoping that someone can help me! Thanks a lot!

推荐答案

在这种情况下是否可以使用WS_EX_LAYERED样式?并使用SetLayeredWindowAttributes()设置透明度,[ ^ ].

谢谢
拉达克里希南(Radhakrishnan G.)
Is it possible to use WS_EX_LAYERED style in this case? and set transparency using SetLayeredWindowAttributes(),[^].

Thanks
Radhakrishnan G.


这篇关于如何在MFC中的透明窗口上绘画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆