Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to display picture stored in enhanced-format metafile (*.emf)
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Pocket PC: custom RAPI class for operating with the Object Store Databases
Pocket PC: Folder Viewer
Writing entries to custom Event Log
Finding out if the current user is the Guest account
FindText -- the hopeless and useless Common Dialog
Reading security permissions for NTFS files and folders
Uploading file to the FTP server using InternetWriteFile
Converting an integer value to a hexadecimal string
Get the power status of your laptop computer
Using GetSysColor
Using shared memory to exchange data between two FoxPro applications
Winsock: how to retrieve the protocol information corresponding to a protocol name
Comparing dimensions of the VFP main window with _SCREEN properties
How to register custom Event Log source
How to view icons stored in executable files (Icon Viewer) - II
Using GetNearestColor
Using the CreateFile
GDI+: rotating images using matrix transformations
Obtaining OS memory performance information
Retrieving IP statistics for the computer
Retrieving various system metrics
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: 129  
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 (107.20.129.212)
4 sec.Example: 'Converting a decimal string to an integer'
2.73 hrs.Function: 'GetIconInfo'
Function group: 'Icon'
8.29 hrs.Function: 'ChooseFont'
10.07 hrs.Example: 'Encapsulating access to the Windows Services in a class'
12.39 hrs.Example: 'Retrieving country-specific dialing information from the Windows Telephony list of countries'
 Example: 'Retrieving information about the main VFP window'
12.78 hrs.Function: 'GetKeyState'
Function group: 'Keyboard Input'
 Example: 'Retrieving a universal form for the drive-based path for a network resource'
1 day(s)Example: 'MapiSendMail class for Visual FoxPro application'
 Example: 'How to drag a Form not using its Titlebar or Caption'
Google
Advertise here!