-
Feb 19th, 2011, 05:34 AM
#1
Thread Starter
Junior Member
minimize / restore from taskbar
Hi,
I m working on a windows application using VB.NET. Using borderless forms. Can anybody tell me how to minimize / restore that application by clicking from taskbar. (I already added minimize button into the form) but also want the functionality from taskbar. Thanks in advance.
-
Feb 19th, 2011, 06:46 AM
#2
Re: minimize / restore from taskbar
You have to add a NotifyIcon from the toolbox (for displaying an icon in the system tray, ie. near to the clock) and a MenuStrip control (for displaying menus on right clicking the NotifyIcon).
Then, create some menus in MenuStrip control(tutorial is here). Write code on clicking the menus, like:
vb Code:
Public Class Form1
'~~~ Minimize (or you can hide)
Private Sub MinimizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinimizeToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
End Sub
'~~~ Back to Normal
Private Sub MaximizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaximizeToolStripMenuItem.Click
Me.WindowState = FormWindowState.Normal
End Sub
End Class
Then attach MenuStrip to NotifyIcon by setting it on the properties window. Then choose an icon for the NotifyIcon. Then run the project.
You'll see an icon in the system tray. Right-click it and choose an option (Minimize or Normal).
Done
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 19th, 2011, 09:08 AM
#3
Thread Starter
Junior Member
Re: minimize / restore from taskbar
Thanks but I need to use this function from taskbar not system tray area.
-
Feb 19th, 2011, 12:35 PM
#4
Re: minimize / restore from taskbar
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 19th, 2011, 01:05 PM
#5
Thread Starter
Junior Member
Re: minimize / restore from taskbar
Case solved.
Code:
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const WS_SYSMENU As Int32 = &H80000
Const WS_MAXIMIZEBOX As Int32 = &H10000
Const WS_MINIMIZEBOX As Int32 = &H20000
cp.Style = cp.Style Or WS_SYSMENU Or WS_MINIMIZEBOX
cp.Style = cp.Style And Not WS_MAXIMIZEBOX
Return cp
End Get
End Property
Last edited by d_a_r_k; Feb 19th, 2011 at 01:09 PM.
-
Feb 19th, 2011, 01:05 PM
#6
Thread Starter
Junior Member
Re: minimize / restore from taskbar
Last edited by d_a_r_k; Feb 19th, 2011 at 01:10 PM.
-
Jan 12th, 2012, 04:34 AM
#7
New Member
Re: minimize / restore from taskbar
Originally Posted by d_a_r_k
Case solved.
Code:
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const WS_SYSMENU As Int32 = &H80000
Const WS_MAXIMIZEBOX As Int32 = &H10000
Const WS_MINIMIZEBOX As Int32 = &H20000
cp.Style = cp.Style Or WS_SYSMENU Or WS_MINIMIZEBOX
cp.Style = cp.Style And Not WS_MAXIMIZEBOX
Return cp
End Get
End Property
can you please tell me how these codes works?
-
Jan 12th, 2012, 05:22 AM
#8
Re: minimize / restore from taskbar
Not all the properties of a Windows.Forms control are exposed as Public or even Protected. The CreateParams property of provides a way to change the appearance and/or behaviour of a control using some the "hidden" properties. You can do this by setting or clearing individual bits in the CreateParams properties Style, ExStyle and ClassStyle. You can find the conventional names for the various style bits and their numeric values in the winuser.h file, which is installed along with Visual Studio somewhere on your system.
You normally make a Form borderless by setting BorderStyle.None. When you do this, it clears the WS_SYSMENU and WS_MINIMIZEBOX bits of the CreateParams.Style. The purpose of d_a_r_k's code is to set these bits back to 1. The effect is to restore some of the behaviour of a bordered form without restoring the visible border. The code also clears the WS_MAXIMIZEBOX bit, which apparently is also necessary.
BB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|