当我的表单显示时,Windows Vista 和 7 运动效果仅应用一次。为什么?
我创建了一个包含两种表单的应用程序。第一个是主要形式,第二个是隐藏形式。 我在 Form1 上放置了一个按钮,并将其设为 ShowModal 作为第二个窗体。在 Win7 上,窗体会显示动画。然后我关闭出现的表单(Form2)并再次单击该按钮。 Form2 出现时没有动画。我每次都想要动画。我应该怎么办?
I created an application with two forms. First one is the main form and second one is hidden.
I placed a button on Form1 and I made it ShowModal the second form. On Win7 the form appears with an animation. Then I close the appeared form (Form2) and I click the button once again. Form2 appears without the animation. I want the animation every time. What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我现在唯一能想到的就是每次要以模态方式显示表单时手动创建表单。为此,请转到项目选项并确保不会自动创建表单。然后做
在我看来,大多数情况下模态表单实际上应该手动创建。
The only thing I can think of right now is to create the form manually each time you want to display it modally. To do this, go to the project options and make sure that the form isn't automatically created. Then do
In my opinion, most often modal forms should in fact be created manually.
好吧,你可以选择不担心它!或者,一个非常快速的技巧是在每次关闭时释放表单,因为动画似乎仅在第一次显示表单时运行。
编辑:另一种方法是在表单关闭时调用 DestroyHandle。我现在猜测,但我想象 Windows 在窗口中的某个位置记录了一个标志,表明动画已显示。一旦设置了该标志,动画就不会再显示。
Well, you could just elect not to worry about it! Alternatively a very quick hack would be to free the form each time it closes since the animation appears to run only on the first time the form is shown.
EDIT: Another approach would be to call DestroyHandle on your form whenever it closes. I'm guessing now, but I imagine that Windows records somewhere in the window a flag indicating that the animation has been shown. Once this flag has been set the animation is never shown again.
作为一种替代方法,可以通过发送表单样式已更改的通知来欺骗窗口,这将使窗口重置当前表单句柄的“秘密标志”。因此,在显示已创建的表单时,将再次应用很酷的显示效果动画。但是,我不能说这样做会造成什么负面影响。
注意:具有类帮助器的代码,此功能/关键字可能在较旧的 IDE 中不可用。
As an alternative way it's possible to fool windows by sending a notification that form's style has been changed, that will make windows reset "secret flag" for current form's handle. Thus, on showing already created form the cool show effect animation will be applied again. However, I can't say what negative effects can be caused by doing this way.
Note: code featured with a class helper, this feature/keyword might be not available in older IDEs.