Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Minimize it?

Posted on 2001-06-11
Medium Priority
Last Modified: 2010-05-02
How do I make a command button in VB that minimizes everything including the program and the stuff running in the background?
Question by:Linky
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 6179620
Try doing an EnumWindows API function, then for each window do the following API:

ShowWindow(hWnd, SW_MINIMIZE)
LVL 53

Accepted Solution

Ryan Chong earned 60 total points
ID: 6179687

Expert Comment

ID: 6179691
You could enumerate through everything which would work, or you could just press the windows key and key m in code which would do the same thing.

Option Explicit

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
  bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LWIN = &H5B

Private Sub Command1_Click()
  Call keybd_event(VK_LWIN, 0, 0, 0)
  Call keybd_event(vbKeyM, 0, 0, 0)
  Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub

Expert Comment

ID: 6179740
I guess from other responses that I may have misunderstood.  I thought you wanted to minimize everything running on the system ("everything including the program and the stuff running in the background.")

That's what the first suggestion is for.

Expert Comment

ID: 6179861

The code I gave him will as well...I assume we are thinking along the same line.  He can either enumerate through all the windows, see if they are appwindows and send a minimize message, or he can simply just press the Win-M key combination in code which will do the same thing, minimize all open windows including his own.  I have done it both ways, but it doesn't matter to me how he chooses to do so.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

636 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