Solved

Minimize it?

Posted on 2001-06-11
5
296 Views
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?
0
Comment
Question by:Linky
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:agriggs
Comment Utility
Try doing an EnumWindows API function, then for each window do the following API:

ShowWindow(hWnd, SW_MINIMIZE)
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 15 total points
Comment Utility
0
 
LVL 6

Expert Comment

by:sharmon
Comment Utility
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
0
 
LVL 2

Expert Comment

by:agriggs
Comment Utility
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.
0
 
LVL 6

Expert Comment

by:sharmon
Comment Utility
Agriggs,

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

Featured Post

Highfive Gives IT Their Time Back

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

15 Experts available now in Live!

Get 1:1 Help Now