Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using SQLBrowseConnect to connect to a data source through a number of iterative calls (SQL Server)
Converting long file names to the short format and vice versa
How to get Special Folders paths
Reading data from INI files
Retrieving the names of all sections in an initialization file
Running a regular FoxPro form while main VFP window is minimized
Using the Semaphore object
Creating hash values for the list of names
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
GetFileOwner - Get the owner of an NTFS file
How to generate UUID values
How to test file attributes (key method for FileExists and DirectoryExists routines)
Saving available locale records into a cursor
Simple MAPI: how to pick an email recipient from Outlook Express address book
GDI+: Color Transparency
Retrieving information about MS-DOS device names using QueryDosDevice (WinNT only)
Returning some basic information for the specified INF file
Using the CopyFile
Winsock: initializing the service in the VFP application
Obtaining MAC address through Address Resolution Protocol (ARP) request
Reading virtual key status values and key names
Retrieving configuration information for the specified server (Win98/Me)
Using an Event Object. Part A: running an application that creates an Event object
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Retrieveing information about the active window (even if it is not owned by the calling process)

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
 
DO decl
#DEFINE GUI_CARETBLINKING  1
#DEFINE GUI_INMOVESIZE     2
#DEFINE GUI_INMENUMODE     4
#DEFINE GUI_SYSTEMMENUMODE 8
#DEFINE GUI_POPUPMENUMODE  16
 
*|typedef struct tagGUITHREADINFO {
*|    DWORD cbSize;       0:4
*|    DWORD flags;        4:4
*|    HWND hwndActive;    8:4
*|    HWND hwndFocus;     12:4
*|    HWND hwndCapture;   16:4
*|    HWND hwndMenuOwner; 20:4
*|    HWND hwndMoveSize;  24:4
*|    HWND hwndCaret;     28:4
*|    RECT rcCaret;       32:16
*|} GUITHREADINFO, *PGUITHREADINFO; total 48 bytes
#DEFINE GUITHREADINFO_SIZE  48
 
LOCAL lnThreaddId
*lnThreadId = GetCurrentThreadId()  && VFP
lnThreadId = 0  && the foreground thread
 
PRIVATE cBuffer, nFlags
cBuffer = Chr(GUITHREADINFO_SIZE) +;
    Repli(Chr(0), GUITHREADINFO_SIZE-1)
 
IF GetGUIThreadInfo(lnThreadId, @cBuffer) = 0
    ? "Error code:", GetLastError()
    RETURN
ENDIF
 
= ins("Thread ID", LTRIM(STR(lnThreadId)))
 
nFlags = buf2dword(SUBSTR(cBuffer, 5,4))
 
= flg(GUI_CARETBLINKING, "The caret is visible")
= flg(GUI_INMOVESIZE, "The thread is in a move or size loop")
= flg(GUI_INMENUMODE, "The thread is in menu mode")
= flg(GUI_SYSTEMMENUMODE, "The thread is in a system menu mode")
= flg(GUI_POPUPMENUMODE, "The thread has an active pop-up menu")
 
= wnd(9, "Active window within the thread")
= wnd(13, "Window that has the keyboard focus")
= wnd(17, "Window that has captured the mouse")
= wnd(21, "Window that owns any active menus")
= wnd(25, "Window in a move or size loop")
= wnd(29, "Window that is displaying the caret")
 
GO TOP
BROW NORMAL NOWAIT
* end of main
 
PROCEDURE flg(lnFlag, lcTitle)
    = ins(lcTitle, Iif(BitAnd(nFlags, lnFlag)=lnFlag, "True","False"))
 
PROCEDURE wnd(lnOffs, lcTitle)
    hWindow = buf2dword(SUBSTR(cBuffer, lnOffs,4))
    lcCaption = GetWindowCaption(hWindow)
    = ins(lcTitle, LTRIM(STR(hWindow)) + ", [" + lcCaption + "]")
 
PROCEDURE ins(cTitle, cValue)
    IF Not USED("csResult")
        CREATE CURSOR csResult (ptitle C(50), pvalue C(200))
    ENDIF
    INSERT INTO csResult VALUES (m.cTitle, m.cValue)
RETURN
 
PROCEDURE decl
    DECLARE INTEGER GetGUIThreadInfo IN user32;
        INTEGER idThread, STRING @lpgui
    DECLARE INTEGER GetCurrentThreadId IN kernel32
    DECLARE INTEGER GetLastError IN kernel32
    DECLARE INTEGER GetWindowText IN user32;
            INTEGER hwnd, STRING @lpString, INTEGER cch    
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
FUNCTION GetWindowCaption(lnWindow)
    LOCAL lnLength, lcText
    lcText = SPACE(250)
    lnLength = GetWindowText(lnWindow, @lcText, Len(lcText))
RETURN Iif (lnLength>0, Left(lcText, lnLength), "#empty#")
 
 
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
2771 bytes  
Created: 2003-01-18 10:55:57  
Modified: 2003-01-18 10:56:14  
Visits in 7 days: 135  
Listed functions:
GetCurrentThreadId
GetGUIThreadInfo
GetLastError
GetWindowText
Printer friendly API declarations
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 (54.224.79.93)
8.49 hrs.Example: 'Converting image file to .ICO file'
 Function: 'EndTask'
10.91 hrs.Function: 'GdipGetImageEncodersSize'
 Function: 'StartService'
Function group: 'Service'
15.81 hrs.Example: 'How to write and read Window Properties for the specified window'
19.16 hrs.Example: 'GDI+: creating scaled copy of image file'
1 day(s)Function: 'FtpFindFirstFile'
 Function: 'NetShareEnum'
Function group: 'Network Management'
 Function: 'TaskDialog'
2 day(s)Example: 'How to position the GETPRINTER() dialog'
Google
Advertise here!