如何在Visual Basic中使用无边框窗体中的最小化动画? [英] How do have the minimising animation in a borderless Form in Visual Basic?

查看:82
本文介绍了如何在Visual Basic中使用无边框窗体中的最小化动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





使用时:

Hi,

When using:

Me.WindowState = FormWindowState.Minimized

,它没有最小化动画。



无论如何都有它吗?我的朋友以前在Visual Basic中做过,所以我无法理解为什么我找不到解决方案。

on a borderless window, it does not have the minimising animation.

Is there anyway to have it? My friend has done it before in Visual Basic, so I can't understand why I can't find a solution for this.

推荐答案

您是否注意到某些版本Windows(我使用的是Windows 7)已经显示了动画最小化?这是最好的方法,因为用户可以为整个系统禁用和启用动画。 您认为有吸引力的功能将被视为非常多用户的一些烦恼,即使您将其设为可选项。我会建议你找到更好的应用你的才能。



尽管如此,你总能实现这样的技巧。您可以随时查看申请表的大小和位置并进行修改。您可以随时阅读活动屏幕的大小:

http://msdn.microsoft.com/en-us/library/system.windows.forms.screen%28v=vs.110%29.aspx [ ^ ]。



因此,您可以创建一个单独的动画线程并在那里执行一些动画:更改表单的大小和位置,使其更小更小的,并且最终使该形式的真实最小化。唯一的问题是:您无法从非UI线程调用与UI相关的任何内容。相反,您需要使用 Invoke System.Windows.Threading的方法。 Dispatcher (对于Forms或WPF)或 System.Windows.Forms.Control (仅限表单)。



您将在我过去的答案中找到有关其工作原理和代码示例的详细说明:

Control.Invoke()与Control.BeginInvoke() [ ^ ],

使用Treeview扫描仪和MD5的问题 [ ^ ]。



另请参阅有关线程的更多参考资料:

如何让keydown事件在不同的操作上运行vb.net中的线程 [ ^ ],

在启用禁用+多线程后控制事件未触发 [ ^ ]。



-SA
Did you notice that some versions of Windows (I'm using Windows 7) already show the animated minimization? This is the best way, because the user can disable and enable animation for the whole system. What you consider as attractive "feature" will be considered as just some annoyance by very many users, even if you make it optional. I would advise you to find better application for your talents.

Nevertheless, you can always implement tricks like that. You can always look at the size and location of your application form and modify it. You can always read the size of your active screen:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen%28v=vs.110%29.aspx[^].

So, you can create a separate "animation thread" and perform some animation there: change the size and location of your form, making it smaller and smaller, and, at the end to the "real" minimization of that form. The only problem is: you cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

—SA


这篇关于如何在Visual Basic中使用无边框窗体中的最小化动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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