Solved

Programmatically click the minimize button in VB.NET

Posted on 2009-07-16
3
964 Views
Last Modified: 2012-05-07
I wrote a .NET app that I would like to minimize programmatically without using me.windowstate.  

Here's the issue -- when I click on a regular button that I made with the code Me.WindowState = Windows.Forms.FormWindowState.Minimized, the form does minimize, but the memory usage does not go down.

However, if I click the standard minimize button in the upper right hand corner of the form, the form minimizes and the memory usage plummets, which is what I'm looking for. (Even though the memory usage figure might only be cosmetic).

My question -- does anyone know how to programmatically simulate clicking the little minimize button at the top right of the form?
0
Comment
Question by:jacksonm1234
3 Comments
 
LVL 12

Expert Comment

by:GuitarRich
Comment Utility
I would imagine that the memory goes down when you click the minimize button as the program then looses focus and is minimized. But when you set your form windowstate the program still has the focus.
After you've clicked on your button to minimize the form, try selecting a different program that is already open and see if the memory usage changes.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
Comment Utility
You can using the windows message loop to send a minimize message to the window.
This link might be helpful.
http://www.thescarms.com/vbasic/ShowWindow.aspx

Also
http://ryanfarley.com/blog/archive/2004/05/10/605.aspx

0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
Comment Utility
Haven't looked at the code in the project linked by CodeCruiser  but I suspect it's using this method?
Public Class Form1
 

    Private Const SW_MINIMIZE As Integer = 6

    Private Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ShowWindow(Me.Handle, SW_MINIMIZE)

    End Sub
 

End Class

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now