Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
CryptoAPI: Collection of Providers class
Enumerating forms supported by a specified printer
Enumerating MIDI output devices
GDI+: rotating images using matrix transformations
Reading entries from Event logs
Retrieving a handle to DLL and address of an exported function in it
Retrieving information specific to the current Time Zone
Retrieving list of files on the FTP directory
Setting the Window Region for a form
Using the GradientFill function
GDI+: converting text strings to images and saving in a graphics file
GDI+: how to make VFP controls visually shake and shudder
Minimizing all running applications
Retrieving configuration information for the specified server (Win98/Me)
Retrieving current settings for an ODBC connection
Retrieving the names of all sections in an initialization file
Using the Semaphore object
Using Video Capture: enumerating installed capture drivers
Winsock: how to retrieve the protocol information corresponding to a protocol number
Building a tree of subdirectories for a given path using FindFile functions
GDI+: Using Scale and Shear transformations
How to check whether the system is 32-bit or 64-bit
How to display the Print property sheet
How to find when the application started
Animating a transition of the VFP form (a wire-frame rectangle)

User rating: 6/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
Before you begin:
A modest sort of animation comparing to what Vista and Mac OS provide.

See also:
  • How to make a VFP form fading out when released
  •  
    DO declare
    #DEFINE IDANI_OPEN    1
    #DEFINE IDANI_CLOSE   2
    #DEFINE IDANI_CAPTION 3
     
    PUBLIC objForm
    objForm = CreateObject("TForm")
    objForm.Visible = .T.
     
    DEFINE CLASS TForm As Form
        BackColor = RGB(157,185,200)
        Width=450
        Height=200
        Caption = "Animating a wire-frame rectangle aroung the form"
     
        PROTECTED left0, top0, width0, height0
     
        ADD OBJECT cmdA AS CommandButton WITH;
        Left=10, Top=15, Width=60, Height=24, Caption="A",;
        Enabled=.T.
     
        ADD OBJECT cmdB AS CommandButton WITH;
        Left=72, Top=15, Width=60, Height=24, Caption="B",;
        Enabled=.F.
     
        ADD OBJECT chAnim As CheckBox WITH;
        Left=12, Top=45, Caption="Animation On",;
        AutoSize=.T., BackStyle=0, Value=.T.
     
    PROCEDURE  Init
        THIS.left0 = THIS.Left
        THIS.top0 = THIS.top
        THIS.width0 = THIS.width
        THIS.height0 = THIS.Height
     
    PROCEDURE  AnimateMove (lcMode)
        LOCAL hWindow, lcFrom, lcTo, lnLeft0, lnTop0,;
            lnWidth0, lnHeight0, lnLeft1, lnTop1,;
            lnWidth1, lnHeight1, lnFlags
     
        hWindow = GetFocus()
     
        lnLeft0 = THIS.Left
        lnTop0 = THIS.top
        lnWidth0 = THIS.width
        lnHeight0 = THIS.Height
     
        IF lcMode = "A"
            lnLeft1 = 500
            lnTop1 = 400
            lnWidth1 = 250
            lnHeight1 = 150
            lnFlags = BitOr(IDANI_OPEN, IDANI_CAPTION)
        ELSE
            lnLeft1 = THIS.left0
            lnTop1 = THIS.top0
            lnWidth1 = THIS.width0
            lnHeight1 = THIS.height0
            lnFlags = BitOr(IDANI_CLOSE, IDANI_CAPTION)
        ENDIF
     
        lcFrom = num2dword(lnLeft0) + num2dword(lnTop0) +;
            num2dword(lnLeft0+lnWidth0-1) + num2dword(lnHeight0+lnTop0-1)
     
        lcTo  = num2dword(lnLeft1) + num2dword(lnTop1) +;
            num2dword(lnWidth1+lnLeft1-1) + num2dword(lnHeight1+lnTop1-1)
     
        IF ThisForm.chAnim.Value
            = DrawAnimatedRects (hWindow, lnFlags, @lcFrom, @lcTo)
        ENDIF
     
        THIS.move (lnLeft1, lnTop1, lnWidth1, lnHeight1)
     
        ThisForm.cmdA.Enabled = ThisForm.cmdB.Enabled
        ThisForm.cmdB.Enabled = !ThisForm.cmdB.Enabled
     
    PROCEDURE  cmdA.Click
        ThisForm.AnimateMove(THIS.Caption)
     
    PROCEDURE  cmdB.Click
        ThisForm.AnimateMove(THIS.Caption)
     
    ENDDEFINE
     
    FUNCTION  num2dword (lnValue)
    #DEFINE m0       256
    #DEFINE m1     65536
    #DEFINE m2  16777216
        LOCAL b0, b1, b2, b3
        b3 = Int(lnValue/m2)
        b2 = Int((lnValue - b3*m2)/m1)
        b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
        b0 = Mod(lnValue, m0)
    RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
     
    PROCEDURE  declare
        DECLARE INTEGER GetFocus IN user32
     
        DECLARE INTEGER DrawAnimatedRects IN user32;
            INTEGER hwnd, INTEGER idAni,;
            STRING @lprcFrom, STRING @lprcTo
     
     

    User rating: 6/10 (1 votes)
    Rate this code sample:
    • ~
    2481 bytes  
    Created: 2002-01-17 19:38:02  
    Modified: 2007-04-23 13:18:12  
    Visits in 7 days: 72  
    Listed functions:
    DrawAnimatedRects
    GetFocus
    Printer friendly API declarations
    My comment:
    Two RECT structures are passed to the DrawAnimatedRects function: one for the initial position of the form, and another for the position the form to be moved to.

    The animation is applied just before moving the form to a new destination. That makes the transition smooth and elegant. Meanwhile you can try to put the animation on and off to feel the difference.
    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.234.180.187)
    3 sec.Function: 'GdipDeleteBrush'
    7.87 hrs.Example: 'URL: splitting into its component parts'
    8.11 hrs.Example: 'Reading STARTUPINFO structure for the current VFP session'
     Function: 'WideCharToMultiByte'
    8.57 hrs.Function: 'CopyImage'
    Function group: 'Resource'
     Example: 'Basic Volume information'
    9.14 hrs.Example: 'How to read email messages using Simple MAPI'
     Gallery
    Page 4
     Function: 'InternetGetConnectedStateEx'
    Function group: 'Internet Functions (WinInet)'
    9.61 hrs.Example: 'Monitoring changes occurring within a directory'
    Google
    Advertise here!