使用分层窗口时是否可以将 AnimateWindow 与 AW_BLEND 一起使用?
我正在使用 UpdateLayeredWindow
显示一个窗口,并希望添加过渡动画。 如果我使用滑动或滚动效果,AnimateWindow
就可以工作(尽管有一些闪烁)。 但是,当我尝试使用 AW_BLEND
产生淡入淡出效果时,我不仅会在动画之后失去任何半透明度(每个像素和整个图像),而且还会出现默认窗口边框。 有没有办法防止边框出现?
I am displaying a window using UpdateLayeredWindow
and would like to add transition animations. AnimateWindow
works if I use the slide or roll effects (though there is some flickering). However, when I try to use AW_BLEND
to produce a fade effect, I not only lose any translucency after the animation (per-pixel and on the entire image), but a default window border also appears. Is there a way to prevent the border from appearing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于我使用的是
UpdateLayeredWindow
,因此SetLayeredWindowAttributes
将不起作用。 这里的图表非常有用。 相反,我只需要在循环中调用UpdateLayeredWindow
,同时减少BLENDFUNCTION
结构的SourceConstantAlpha
成员。 事实上,如果 Alpha 就是这些,那么指向 BLENDFUNCTION 结构的指针、分层窗口的句柄和标志是我需要传递到 UpdateLayeredWindow 的唯一内容在改变。Since I'm using
UpdateLayeredWindow
,SetLayeredWindowAttributes
will not work. The diagram here was pretty useful. Instead, I just need to callUpdateLayeredWindow
in a loop while decreasing theSourceConstantAlpha
member of theBLENDFUNCTION
structure. In fact, the pointer to theBLENDFUNCTION
structure, the handle to the layered window, and the flags are the only things I needed to pass intoUpdateLayeredWindow
if the alpha is all that is changing.我发现成功淡入/淡出窗口的唯一方法(没有您所描述的复杂性)是首先使用
WS_EX_LAYERED
扩展样式创建一个窗口。 然后,我启动一个计时器(30 毫秒),通过调用以下内容逐渐淡出窗口:其中
WINDOW_ALPHA
是 23(似乎看起来最好),而m_nAnimationCount
是一个计数0 到 10(如果淡入淡出,则为 10 到 0)。如果您发现更好的方法来做到这一点,我很有兴趣找出答案。
The only way I've found to successfully fade up/down a window (without the complications you're describing) is by first creating a window with the
WS_EX_LAYERED
extended style. I then start a timer (30ms) that gradually fades the window by calling something like:where
WINDOW_ALPHA
is 23 (seems to look the best), andm_nAnimationCount
is a count from 0 to 10 (or 10 to 0 if fading down).If you discover a better way of doing this, I'd be interested to find out.