Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Winsock: changing the byte ordering
Attaching menu to a top-level form
Converting command-line string to a set of Unicode argument strings (WinNT only)
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Enumerating network interfaces on the local computer
Finding out if the current user is the Guest account
GDI+: reading and writing metadata in JPEG and TIFF files
How to enumerate terminal servers within the specified Windows domain
How to release and renew a lease on an IP address previously obtained through Dynamic Host Configuration Protocol (DHCP)
Pocket PC: base class
Pocket PC: custom RAPI class for operating with the System Registry
Pocket PC: retrieving data from the Contacts Database
Quering waveform-audio output devices
Saving HKEY_LOCAL_MACHINE\\Software\\ODBC Registry Entries to an XML file
Verifying a file using the Authenticode policy provider
Enumerating Processes -- WinNT
GDI+: creating scaled copy of image file
GDI+: retrieving list of available image encoders and image decoders
Retrieving various system metrics
Using shared memory to exchange data between two FoxPro applications
Winsock: retrieving the standard host name and IP address for the local machine
Converting an integer value to a hexadecimal string
How to create a desktop shortcut (shell link)
Testing an ODBC connection for supporting specific functionality
Retrieving top-child window for the VFP form

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:
Push the button on the form to display the top-child window propeties for this form.

This code demonstrates that the native VFP controls (ListBox, ComboBox, TextBox, Label, EditBox etc.) are windowless. They are not windows.
 
PUBLIC frm
frm = CreateObject("Tform")
frm.Visible = .T.
 
DEFINE CLASS Tform As Form
Width=400
Height=300
AutoCenter = .T.
 
    ADD OBJECT lst As ListBox WITH;
        Left=10, Top=10, Width=150, Height=270
 
    ADD OBJECT lbl As Label WITH;
        Caption="Label1", Left=165, Top=7,;
        AutoSize=.T.
 
    ADD OBJECT txt As TextBox WITH;
        Left=165, Top=24, Width=220
 
    ADD OBJECT cmb As ComboBox WITH;
        Left=165, Top=70, Width=60
 
    ADD OBJECT cmd As CommandButton WITH;
        Left=260, Top=70, Height=24, Width=124,;
        Caption="List Child Windows"
 
    ADD OBJECT edt As EditBox WITH;
        Left=165, Top=120, Width=220, Height=60
 
PROCEDURE Init
    * this ActiveX control is the top-child window for the form
    THIS.AddComCtrl
 
PROCEDURE AddComCtrl
    THIS.AddObject ("ComCtrl", "OLEControl", "MSComctlLib.TreeCtrl")
    WITH THIS.ComCtrl
        .Left = 165
        .Top = 200
        .Width = 220
        .Height = 70
 
        root = .Nodes.Add(,,"R","Root")
        .Nodes.Add("R", 4, "c1", "Child 1")
        .Nodes.Add("R", 4, "c2", "Child 2")
        .Nodes.Add("R", 4, "c3", "Child 3")
        root.Expanded = .T.
 
        .Visible = .T.
    ENDWITH
 
PROCEDURE cmd.Click
    ThisForm.ListChildWindows
 
PROCEDURE ListChildWindows
#DEFINE GW_HWNDNEXT 2
#DEFINE GW_CHILD 5
    DECLARE INTEGER GetFocus IN user32
    DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag
 
    LOCAL hFormWindow, hTopChild
    hFormWindow = GetFocus()
    hTopChild = GetWindow(hFormWindow, GW_CHILD)
 
    THIS.PrintWinData("This Form:", hFormWindow)
    IF hTopChild <> 0
        THIS.PrintWinData("Top child:", hTopChild)
    ELSE
        ACTI SCREEN
        ? "No top child window found"
    ENDIF
 
FUNCTION PrintWinData(lcTitle, hWindow)
    LOCAL lcCaption, lnWinLeft, lnWinTop, lnWinRight, lnWinBottom
    lcCaption = THIS.GetWindowCaption(hWindow)
    STORE 0 TO lnWinLeft, lnWinTop, lnWinRight, lnWinBottom
    THIS.GetDim(hWindow, @lnWinLeft, @lnWinTop, @lnWinRight, @lnWinBottom)
 
    ACTI SCREEN
    ? lcTitle, "Left:", lnWinLeft, "Top:", lnWinTop,;
        "Right:", lnWinRight, "Bottom:", lnWinBottom,;
        "Caption:", lcCaption
 
FUNCTION GetWindowCaption(hWindow)
    DECLARE INTEGER GetWindowText IN user32;
        INTEGER hwnd, STRING @lpString, INTEGER cch
    LOCAL lnLength, lcText
    lcText = SPACE(250)
    lnLength = GetWindowText(hWindow, @lcText, Len(lcText))
RETURN Iif(lnLength>0, Left(lcText, lnLength), "#empty#")
 
FUNCTION GetDim(hWindow, lnWinLeft, lnWinTop, lnWinRight, lnWinBottom)
    DECLARE SHORT GetWindowRect IN user32 INTEGER hwnd, STRING @ lpRect
    LOCAL lcBuffer
    lcBuffer = REPLI(Chr(0), 16)
    = GetWindowRect(hWindow, @lcBuffer)
    lnWinLeft = buf2dword(SUBSTR(lcBuffer, 1,4))
    lnWinTop = buf2dword(SUBSTR(lcBuffer, 5,4))
    lnWinRight = buf2dword(SUBSTR(lcBuffer, 9,4))
    lnWinBottom = buf2dword(SUBSTR(lcBuffer, 13,4))
ENDDEFINE
 
FUNCTION buf2dword(lcBuffer) 
RETURN;
    Asc(SUBSTR(lcBuffer, 1,1)) + ;
    Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
2977 bytes  
Created: 2001-12-09 16:47:40  
Modified: 2006-02-06 08:51:02  
Visits in 7 days: 65  
Listed functions:
GetFocus
GetWindow
GetWindowRect
GetWindowText
Printer friendly API declarations
My comment:
Only if an ActiveX control is added to the form (ThisForm.ComCtrl in this example), it appears to be the top-child window for the form.

This is interesting: the VFP form with ThisForm.ShowWindow=2 has a top-child window inside even with no controls added to it. It looks like its client area is this top-child window.
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.19.155.235)
4 sec.Example: 'Custom FTP Class for Visual FoxPro application'
6.28 hrs.Function: 'CreateHardLink'
Function group: 'File Management'
 Function: 'LookupAccountName'
Function group: 'Security'
9.08 hrs.Example: 'Displaying all TCP connections for the local system'
 Example: 'Retrieving geometrical parameters of the system desktop window'
22.03 hrs.Example: 'Displaying bitmap using the AlphaBlend function'
 Example: 'Creating a directory on the FTP'
Language: 'C#'
1 day(s)Function: 'GetProductInfo'
 Example: 'How to play a waveform sound (a WAV file in particular)'
 Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
Google
Advertise here!