PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 minimize / restore from taskbar-VBForums
Results 1 to 8 of 8

Thread: minimize / restore from taskbar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    27

    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.

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,641

    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:
    1. Public Class Form1
    2.  
    3.     '~~~ Minimize (or you can hide)
    4.     Private Sub MinimizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinimizeToolStripMenuItem.Click
    5.         Me.WindowState = FormWindowState.Minimized
    6.     End Sub
    7.  
    8.     '~~~ Back to Normal
    9.     Private Sub MaximizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaximizeToolStripMenuItem.Click
    10.         Me.WindowState = FormWindowState.Normal
    11.     End Sub
    12.  
    13. 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,...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    27

    Re: minimize / restore from taskbar

    Thanks but I need to use this function from taskbar not system tray area.

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,641

    Re: minimize / restore from taskbar

    Quote Originally Posted by d_a_r_k View Post
    Thanks but I need to use this function from taskbar not system tray area.
    Oh! Sorry, I didn't read the question carefully...

    I don't have a solution for this. But someone will provide a good one


    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,...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    27

    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.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    27

    Re: minimize / restore from taskbar

    Sorry for dbl post.
    Last edited by d_a_r_k; Feb 19th, 2011 at 01:10 PM.

  7. #7
    New Member
    Join Date
    Jan 2012
    Posts
    10

    Re: minimize / restore from taskbar

    Quote Originally Posted by d_a_r_k View Post
    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?

  8. #8
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,016

    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
  •  



Featured


Click Here to Expand Forum to Full Width