Using Win32 functions in Visual FoxPro Image Gallery
Window
..msdn
CloseWindow
CreateWindow
CreateWindowEx
DestroyWindow
EndTask
FindWindow
FindWindowEx
GetAncestor
GetClientRect
GetDesktopWindow
GetForegroundWindow
GetGUIThreadInfo
GetParent
GetShellWindow
GetWindow
GetWindowInfo
GetWindowPlacement
GetWindowRect
GetWindowText
GetWindowTextLength
GetWindowThreadProcessId
InternalGetWindowText
IsChild
IsIconic
IsWindow
IsWindowVisible
IsZoomed
MoveWindow
RealGetWindowClass
SetForegroundWindow
SetLayeredWindowAttributes
SetParent
SetWindowPos
SetWindowText
ShowWindow
SwitchToThisWindow
Code examples:
Minimizing all running applications
Minimizing all running applications

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
It is almost the same if you would select the Minimize All Windows command from the Windows toolbar menu.
 
DO decl
LOCAL hWinActive, hWindow, lcWinText, hWinCount, lnWinIndex
hWinActive = GetActiveWindow()
hWindow = -1
hWinCount = 0
 
#DEFINE GW_HWNDFIRST  0
#DEFINE GW_HWNDLAST   1
#DEFINE GW_HWNDNEXT   2
 
DO WHILE hWindow <> GetWindow (hWinActive, GW_HWNDLAST)
    IF hWindow = -1
        hWindow = GetWindow(hWinActive, GW_HWNDFIRST)
    ELSE
        hWindow = GetWindow(hWindow, GW_HWNDNEXT)
    ENDIF
 
    IF IsWindow(hWindow) <> 0;
        And IsWindowVisible(hWindow) <> 0;
        And GetWindowTextLength(hWindow) > 0
 
        lcWinText = GetWinText(hWindow)
 
        * storing suitable window handles to an array
        IF Not "Program Manager" $ lcWinText
            hWinCount = hWinCount + 1
            DIMEN arrWin[hWinCount]
            arrWin[hWinCount] = hWindow
        ENDIF
    ENDIF
ENDDO
 
FOR lnWinIndex=1 TO hWinCount
    If IsIconic(arrWin[lnWinIndex]) = 0
        = CloseWindow(arrWin[lnWinIndex])
    ENDIF
ENDFOR
* end of main
 
FUNCTION  GetWinText(hWindow)
    LOCAL lnBufsize, lcBuffer
    lnBufsize = 1024
    lcBuffer = Repli(Chr(0), lnBufsize)
    lnBufsize = GetWindowText(hWindow, @lcBuffer, lnBufsize)
RETURN  Iif(lnBufsize=0, "", Left(lcBuffer,lnBufsize))
 
PROCEDURE  decl
    DECLARE INTEGER GetActiveWindow  IN user32
    DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag
    DECLARE INTEGER IsWindow IN user32 INTEGER hWnd
    DECLARE INTEGER IsWindowVisible IN user32 INTEGER hWnd
    DECLARE INTEGER GetWindowTextLength IN user32 INTEGER hWnd
 
    DECLARE INTEGER GetWindowText IN user32;
        INTEGER hwnd, STRING @lpString, INTEGER cch
 
    DECLARE INTEGER CloseWindow IN user32 INTEGER hWnd
    DECLARE INTEGER IsIconic IN user32 INTEGER hWnd
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1614 bytes  
Created: 2002-01-10 18:25:51  
Modified: 2008-12-03 15:26:21  
Visits in 7 days: 153  
Listed functions:
CloseWindow
GetActiveWindow
GetWindow
GetWindowText
GetWindowTextLength
IsIconic
IsWindow
IsWindowVisible
Printer friendly API declarations
My comment:
The GetWindow is used to obtain handles to all windows siblings to the main VFP window, excluding the Program Manager window.

Then the CloseWindow is applied to every handle to minimize the window. This name is quite obscure, because the windows are in fact minimized not being closed by this function.

Compare with the DestroyWindow. This name gives a clear idea of what this function really does.

See also:
Microsoft Help and Support: How to re-create the Show Desktop icon on the Quick Launch bar
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (50.16.36.153)
6 sec.Function: 'GetObjectType'
Function group: 'Device Context'
1.46 hrs.Example: 'How to make a VFP form fading out when released (GDI version)'
3.01 hrs.Function: 'CreateProcessAsUser'
Function group: 'Process and Thread'
4.47 hrs.Example: 'How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory'
 Example: 'Encapsulating access to the Windows Services in a class'
4.69 hrs.Function: 'AVIStreamLength'
Function group: 'Windows Multimedia'
 Example: 'Extensible Storage Engine class library'
6.43 hrs.Example: 'How to display Windows On-Screen Keyboard'
7.19 hrs.Function: 'CeCreateDirectory'
Function group: 'Remote Application Programming (RAPI)'
 Example: 'Using the FindMediaType function'
Google
Advertise here!