INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

Minimize All Windows (Show Desktop) by craigsboyd
Posted: 4 Oct 03 (Edited 18 Feb 05)

Slighthaze = NULL

Below I am providing two ways to minimize all of the applications (top level windows) currently running.  Cut-N-Paste the code below into prg file(s) and run the different alternatives to see how it works.

******************FIRST WAY TO DO IT*******************

*!* Let's Minimize and UnMinimize All Top Level Windows

#DEFINE WM_COMMAND    0x111
DECLARE INTEGER FindWindow IN user32 STRING, STRING
DECLARE INTEGER SendMessage IN user32 INTEGER, INTEGER, INTEGER, INTEGER
SendMessage(FindWindow("Shell_TrayWnd", NULL), WM_COMMAND, 415, 0) &&Minimize All
=INKEY(2) &&Give windows a chance to catch up
MESSAGEBOX("Now we will undo the minimize")
SendMessage(FindWindow("Shell_TrayWnd", NULL), WM_COMMAND, 416, 0) &&Undo Minimize

******************SECOND WAY TO DO IT*******************

*!* Let's Minimize All Top Level Windows

DECLARE INTEGER CloseWindow IN user32 INTEGER
DECLARE INTEGER GetActiveWindow IN user32
DECLARE INTEGER GetWindow IN user32 INTEGER, INTEGER
DECLARE INTEGER GetWindowTextLength IN user32 INTEGER
DECLARE INTEGER IsIconic IN user32 INTEGER
DECLARE INTEGER IsWindow IN user32 INTEGER
DECLARE INTEGER IsWindowVisible IN user32 INTEGER

LOCAL nActive, nCounter, nHwnd, nIndex
LOCAL cWindowCaption

nCounter = 0
nHwnd = -1

nActive = GetActiveWindow()

DO WHILE nHwnd != GetWindow(nActive, 1) &&1 = FIRST WINDOW
    IF nHwnd != -1
        nHwnd = GetWindow(nHwnd, 2) &&2 = NEXT WINDOW
    ELSE
        nHwnd = GetWindow(nActive, 0) &&0 = LAST WINDOW
    ENDIF

    IF GetWindowTextLength(nHwnd) > 0 AND IsWindow(nHwnd) != 0 AND IsWindowVisible(nHwnd) != 0
        nCounter = nCounter + 1
        DIMENSION aryWindows(nCounter)
        aryWindows(nCounter) = nHwnd
    ENDIF
ENDDO

FOR nIndex=1 TO nCounter
    If IsIconic(aryWindows(nIndex)) = 0
        IF CloseWindow(aryWindows(nIndex)) = 0
            *!* Non-existant window or something went wrong
        ENDIF
    ENDIF
ENDFOR

******************SCARY WAY TO DO IT*******************

*!* Use the following with EXTREME CAUTION
*!* Will minimize all windows including hidden ones
*!* Won't break anything but you will have a
*!* window mess on your hands  It is kind
*!* of informative so for the brave go ahead
*!* and uncomment it and run it
*!*    #DEFINE HWND_BROADCAST    0xffff
*!*    #DEFINE SC_MINIMIZE       0xF020
*!* #DEFINE WM_SYSCOMMAND   0x112
*!* DECLARE INTEGER SendMessage IN user32 INTEGER, INTEGER, INTEGER, INTEGER
*!* SendMessage (HWND_BROADCAST, WM_SYSCOMMAND, SC_MINIMIZE, 0)


Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close