Using Win32 functions in Visual FoxPro Image Gallery
Keyboard Input
..msdn
ActivateKeyboardLayout
BlockInput
EnableWindow
GetActiveWindow
GetAsyncKeyState
GetFocus
GetKBCodePage
GetKeyboardLayout
GetKeyboardLayoutList
GetKeyboardLayoutName
GetKeyboardState
GetKeyNameText
GetKeyState
IsWindowEnabled
keybd_event
MapVirtualKey
RegisterHotKey
SetFocus
SetKeyboardState
ToAscii
UnregisterHotKey
VkKeyScan
Code examples:
An alternative way of setting Form.Closable to False
Animating a transition of the VFP form (a wire-frame rectangle)
Attaching menu to a top-level form
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Creating a clipping region from the path selected into the device context of a form
Disabling drawing in the VFP form
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Drawing a window caption using the DrawCaption routine
Drawing standard Windows icons
Form Magnifier
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
GDI+: sending image of FoxPro form to printer
GetFocus returns a HWND value
How to block the ALT+TAB shortcut (WinXP)
How to block the PrintScreen key
How to copy the image of a form to the Clipboard using Bitmap API functions
How to create transparent areas inside a form -- punching holes in the form
How to drag a Form not using its Titlebar or Caption
How to intercept window messages sent to VFP form
How to print FoxPro form
How to print FoxPro form -- II
How to put a horizontal text scrolling on the form (a news line, marquee)
How to put a vertical text scrolling on the form (a movie cast)
How to start the screen saver and how to find whether the screen saver is active
How to view icons stored in executable files (Icon Viewer)
Placing a button on the VFP form as a new child window
Retrieving top-child window for the VFP form
Retrieving window and menu help context identifiers
Round FoxPro form
Running a regular FoxPro form while main VFP window is minimized
Setting the mouse capture to the specified window
Setting the Window Region for a form
Shortcut Menu Class
Storing screen shot of a form to bitmap file
Storing screen shot of a form to enhanced metafile (*.emf)
The window and its ancestors
Tracking mouse movement to detect when to start dragging
Using Common Controls: the Header Control
Using FrameRgn for displaying system colors
Using IsChild() for testing ThisForm.ShowWindow property
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: 253  
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-2014 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.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.205.205.47)
2 sec.Function: 'DrawIcon'
4 sec.Example: 'How to change display settings: screen resolution, screen refresh rate'
Language: 'C#'
6 sec.Function: 'Escape'
8 sec.Example: 'Enumerating ODBC drivers available on the local computer'
10 sec.Function: 'RtlCompressBuffer'
12 sec.Function: 'mmioCreateChunk'
Function group: 'Windows Multimedia'
15 sec.Function: 'waveOutOpen'
Function group: 'Windows Multimedia'
Google
Advertise here!