Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Winsock: sending email messages (SMTP, port 25)
Mapping and disconnecting network drives
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Disk in drive A:
How to display the Properties dialog box for a file (ShellExecuteEx)
Enumerating network resources
Detecting changes in connections to removable drives (VFP9)
How to download a file from the FTP server using FtpGetFile
Using EnumPrinters function to enumerate locally installed printers
Splash Screen for the VFP application
How to play AVI file on the _screen
Retrieving the name of the network resource associated with a local device
Custom HttpRequest class (WinHTTP)
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Creating a console window for Visual FoxPro application
Custom FTP Class for Visual FoxPro application
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: 93  
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)
34.52 min.Example: 'Storing screen shot of a form to enhanced metafile (*.emf)'
34.62 min.Example: 'How to display the port-configuration dialog box for a port on the specified server'
5.46 hrs.Function: 'GetCurrentThreadId'
Function group: 'Process and Thread'
6.28 hrs.Example: 'Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera'
Language: 'C++'
17.29 hrs.Example: 'Using the heap of the calling process to allocate memory blocks'
 Example: 'Winsock: how to retrieve the protocol information corresponding to a protocol name'
17.77 hrs.Example: 'Sending email messages with Simple MAPI'
18.15 hrs.Function: 'SCardListReaderGroups'
 Example: 'Using the SetErrorMode for determining if a floppy drive is ready'
18.72 hrs.
Function group: 'Virtual Hard Disk (Win7)'
Google
Advertise here!