Programmatically click the minimize button in VB.NET
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?
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.
Mike TomlinsonMiddle School Assistant TeacherCommented:
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 SubEnd Class
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
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.