以编程方式最小化/恢复窗口,跳过动画效果
我需要对窗口列表执行多项操作(最小化其中一些,恢复其他),以便立即在两组或多组窗口之间切换。
这样做的问题是最小化和恢复窗口时可以看到的动画。整个过程看起来很糟糕,所有这些动画都进进出出、上下移动。
但是,我无法禁用这些动画,因为这是针对其他计算机的,我不想更改其他人的设置,而且当您仅最小化/恢复一个窗口时(即当您手动执行此操作时),这些动画实际上很有用,因为您可以看到正在发生什么,但是对于一次在多个窗口上以编程方式执行此操作,这并不好。
我当前正在使用 SendMessage
函数发送带有参数 SC_MINIMIZE
/SC_RESTORE
的 WM_SYSCOMMAND
消息。不知道还有没有别的办法。
所以,问题是:
如何在没有动画效果的情况下以编程方式最小化/恢复窗口?
PS:编程语言并不重要。我可以使用完成此任务所需的任何语言。
I need to perform several operations on a list of windows (minimize some of them, restore others) in order to switch between two or more set of windows at once.
The problem with this are those animations you can see when minimizing and restoring a window. The whole process look terrible with all those animations going in and out, up and down.
I cannot, however, disable those animations because this is for other computers and i dont want to change other people's settings, plus those animations are actually useful when you minimize/restore one window only (i.e. when YOU do it manually) because you can see what is happening, but for doing it programmatically on several windows at a time, it's not nice.
I'm currenlty using the SendMessage
function to send the WM_SYSCOMMAND
message with params SC_MINIMIZE
/SC_RESTORE
. I dont know whether there is another way.
So, the question:
How can I minimize/restore a window programatically without the animation effect??
PS: The programming language is not important. I can use any language that's nessesary for accomplishing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SetWindowPlacement
与SW_SHOWMINIMIZED
或SW_RESTORE
适合WINDOWPLACement
似乎绕过了窗口动画。我会密切关注操作系统未来版本的功能,因为文档没有提及任何有关动画的内容。SetWindowPlacement
withSW_SHOWMINIMIZED
orSW_RESTORE
as appropriate forshowCmd
inWINDOWPLACEMENT
seems to bypass window animation. I'd keep an eye on the functionality for future versions of the OS though since documentation does not mention anything about animation.您可以暂时禁用动画,然后恢复用户的原始设置。
构造抑制器时,它会记住用户的原始设置并关闭动画。析构函数恢复原始设置。通过使用 c'tor/d'tor,您可以确保在重新排列代码引发异常时恢复用户的设置。
这里有一个小的漏洞窗口。理论上,用户可以在操作过程中更改设置,然后你就会把原来的设置恢复回来。这种情况非常罕见,而且也没有那么糟糕。
You could temporarily disable the animations and then restore the user's original setting.
When the suppressor is constructed, it remembers the user's original setting and turns off the animation. The destructor restores the original settings. By using a c'tor/d'tor, you ensure that the user's settings are restored if your rearranging code throws an exception.
There is a small window of vulnerability here. In theory, the user could change the setting during the operation, and then you'll slam the original setting back. That's extremely rare and not really that bad.
隐藏怎么样>最小化>展示 ?
How about Hide > Minimize > Show ?