Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Minimizing all running applications
Number of clipboard formats available
Reading the state of mouse buttons within DO WHILE loop
Setting properties of the window: caption and user-defined value
Tracking mouse movement to detect when to start dragging
Accessing Adobe Reader 7.0 main menu from VFP application
Accessing Windows Control Panel from VFP Application
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Enumerating the subkeys for a given registry key
GDI+: Using Scale and Shear transformations
How to delete all print jobs for a printer
MSMQ: how to open a queue
Obtaining MAC address through Address Resolution Protocol (ARP) request
Retrieving a universal form for the drive-based path for a network resource
Using Shell for performing operations on files
Displaying printer-properties Property Sheet for the specified printer
Finding the application, icon and friendly names associated with a file name
How to test file attributes (key method for FileExists and DirectoryExists routines)
Listing INF files in a specified directory
PocketPC: custom RAPI class for executing routines on remote Windows CE device
Using the heap of the calling process to allocate memory blocks
How to delete file on FTP server
How to run FoxPro application under different user name (impersonating user)
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)
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: 64  
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-2018 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.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.92.197.82)
17 sec.Function: 'CeGetSpecialFolderPath'
Function group: 'Remote Application Programming (RAPI)'
43 sec.Function: 'AVIFileInfo'
Function group: 'Windows Multimedia'
56 sec.Function: 'mixerGetNumDevs'
Function group: 'Windows Multimedia'
1.12 min.All Functions
1.37 min.Function: 'waveOutUnprepareHeader'
Function group: 'Windows Multimedia'
1.58 min.Function: 'AVIFileRelease'
Function group: 'Windows Multimedia'
1.78 min.Function: 'GetLongPathName'
Function group: 'File Management'
2.02 min.Function: 'GdipDrawImageRectI'
Function group: 'GDI+ Graphics'
2.23 min.Function: 'SetupDiGetClassImageIndex'
Function group: 'Setup API functions'
2.42 min.Example: 'Accessing examples contained in this reference from a VFP application'
Google
Advertise here!