Click here to Skip to main content
15,887,401 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

When using:
VB
Me.WindowState = FormWindowState.Minimized
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.
Posted
Updated 2-Nov-14 0:05am
v4
Comments
Richard MacCutchan 2-Nov-14 7:00am    
Why not ask your friend how he/she does it?
Member 11199542 2-Nov-14 7:07am    
Offline, and has been for a while unfortunately.
Richard MacCutchan 2-Nov-14 11:47am    
Some friend!
[no name] 2-Nov-14 12:19pm    
If setting a form to borderless, disables the API responsible for the 3D animation, you would need to initiate this action with an API call to shadow the standard method of a 3D form being minimized by use of overloads. (Search and you will find some examples.)

When minimizing the form, you would call the appropriate API to Minimize the window as an override using windows API. Checkout www.pinvoke.net for a list of API calls. One of the options is: http://pinvoke.net/default.aspx/Enums/SHOWWINDOW_FLAGS.html as a starting point.
Search: minimize. If you want that 3D animation back, you may need to do a bit of poking around.

You will notice that the Animation is there when you maximize back up, but not when the minimize call is made from the WindowState in the form.

1 solution

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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900