Using Win32 functions in Visual FoxPro Image Gallery
Window
..msdn
CloseWindow
CreateWindow
CreateWindowEx
DestroyWindow
EndTask
FindWindow
FindWindowEx
GetAncestor
GetClientRect
GetDesktopWindow
GetForegroundWindow
GetGUIThreadInfo
GetParent
GetShellWindow
GetWindow
GetWindowInfo
GetWindowPlacement
GetWindowRect
GetWindowText
GetWindowTextLength
GetWindowThreadProcessId
InternalGetWindowText
IsChild
IsIconic
IsWindow
IsWindowVisible
IsZoomed
MoveWindow
RealGetWindowClass
SetForegroundWindow
SetLayeredWindowAttributes
SetParent
SetWindowPos
SetWindowText
ShowWindow
SwitchToThisWindow
Code examples:
Accessing Adobe Reader 7.0 main menu from VFP application
Extended MessageBox Class
How to change the name and the size of the font in the MessageBox dialog
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to position the GETPRINTER() dialog
Listing child windows for the Windows desktop
Minimizing all running applications
Obtaining window class name for the main VFP window
Reading the structure of VFP main menu
Retrieveing information about the active window (even if it is not owned by the calling process)
Retrieving top-child window for the VFP form
Scanning a hierarchy of child windows down from the Windows Desktop
Scanning the hierarchy of child windows down from the main VFP window
Simple Window Viewer
Terminating all running applications from a VFP program
The window and its ancestors
Who is the first in viewing the Clipboard
Who owns the Windows Clipboard
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: 67  
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 (107.22.127.92)
8.5 hrs.Example: 'Winsock: initializing the service in the VFP application'
11.17 hrs.Function: 'WTSUnRegisterSessionNotification'
 Example: 'How to intercept window messages sent to VFP form'
18.39 hrs.Example: 'Using Multimedia Command Strings to play MIDI files'
 Example: 'Displaying dimmed window behind VFP top-level form'
1 day(s)Function: 'GdipFillRectangle'
 Function: 'EnumServicesStatus'
Function group: 'Service'
 Example: 'How to print a bitmap file'
 Function: 'InternetCheckConnection'
Google
Advertise here!