Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to display Windows On-Screen Keyboard
How to print a bitmap file
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Winsock: sending email messages (SMTP, port 25)
System Image List Viewer
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Custom HttpRequest class (WinHTTP)
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Printing Image File, programmatically set print page orientation to landscape
How to convert a bitmap file to monochrome format (1 bpp)
The window and its ancestors
Mapping and disconnecting network drives
Using EnumPrinters function to enumerate locally installed printers
How to download a file from the FTP server using FtpGetFile
Custom FTP Class for Visual FoxPro application
Displaying the associated icons and descriptions for files and folders
Displaying icons in the system tray (VFP9)
How to activate Windows Calculator
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Drawing Windows predefined bitmaps using the LoadBitmap functions
Sending email messages with Simple MAPI
Simulating DOEVENTS

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
 
PUBLIC frm
frm = CreateObject ("Tform")
frm.Visible = .T.
 
DEFINE CLASS Tform As Form
    Width=500
    Height=200
    Caption="Simulating DOEVENTS"
    AutoCenter=.T.
 
    ADD OBJECT sh As Shape WITH;
        Left=20, Width=0,;
        Top=100, Height=70, BackColor=Rgb(192,192,250),;
        BorderStyle=0
 
    ADD OBJECT cmdStart As CommandButton WITH;
        Left=10, Top=10, Height=25, Width=80,;
        Caption="Start"
 
    ADD OBJECT cmdStop As CommandButton WITH;
        Left=THIS.cmdStart.Left+THIS.cmdStart.Width+2,;
        Top=THIS.cmdStart.Top, Height=25, Width=80,;
        Caption="Stop"
 
    LoopState = .F.
 
PROCEDURE  Init
    DECLARE INTEGER GetQueueStatus IN user32 INTEGER flags
    ThisForm.stopLoop
ENDPROC
 
PROCEDURE  startLoop
* this method emulates a time-consuming process
    THIS.LoopState = .T.
    LOCAL ii
    CREATE CURSOR cs (dt T)
    DO WHILE THIS.LoopState
        WITH ThisForm.sh
            .Width = .Width + 10
            IF .Width > ThisForm.Width - .Left*2
                .Width = 0
            ENDIF
        ENDWITH
 
        FOR ii=1 TO 10000
            INSERT INTO cs VALUES (datetime())
 
        * this line makes a difference
        * allowing VFP to take a breath and analyze the user input
        * though it slows the process down
            ThisForm._doEvents()
        * ----------------------------
        ENDFOR
    ENDDO
ENDPROC
 
PROCEDURE  stopLoop
    ThisForm.LoopState = .F.
ENDPROC
 
PROCEDURE  cmdStart.Click
    ThisForm.startLoop
ENDPROC
 
PROCEDURE  cmdStop.Click
* actually there is no need to call StopLoop from this event
ENDPROC
 
PROCEDURE  _doEvents
#DEFINE QS_MOUSEBUTTON  4
#DEFINE QS_MOUSEMOVE    2
#DEFINE QS_MOUSE        6  && QS_MOUSEMOVE Or QS_MOUSEBUTTON
 
    * catching mouse messages
    IF GetQueueStatus(QS_MOUSEBUTTON) <> 0
    * if mouse button pressed -- we are here inside
        LOCAL obj
 
        * obtaining a reference to the object 
        * that is under the current mouse position
        obj = SYS(1270)
 
        * if this particular button is clicked,
        * then we stop the process
        IF obj.Name = "CMDSTOP"
            ThisForm.stopLoop
        ENDIF
 
        * there is another way -- getting mouse cursor position
        * and testing it against the button rectangle
        * possibly it would work faster than SYS function
        * and no undocumented functionality would be involved -- try
    ENDIF
ENDDEFINE
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
2233 bytes  
Created: 2001-10-09 22:13:39  
Modified: 2002-02-07 09:53:30  
Visits in 7 days: 81  
Listed functions:
GetQueueStatus
Printer friendly API declarations
My comment:
This example shows how to track user input while executing time-consuming process. This technique is especially useful for VFP3, because this version has no DOEVENTS function implemented.
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.16.108.167)
1.53 hrs.Example: 'Extensible Storage Engine class library'
Language: 'Visual FoxPro'
 Function: 'CeFindNextDatabaseEx'
Function group: 'Remote Application Programming (RAPI)'
 Example: 'How to find which fonts Windows uses for drawing captions, menus and message boxes'
1.63 hrs.Example: 'Retrieving long values associated with the class of the VFP window'
 Example: 'Using IsChild() for testing ThisForm.ShowWindow property'
 Function: 'CeWriteFile'
1.85 hrs.Function: 'EnumDisplayDevices'
 Example: 'Adding user-defined items to the Control Menu of VFP form (requires VFP9)'
1.86 hrs.Example: 'Retrieving information about the main VFP window'
2.08 hrs.Example: 'How to enumerate, add and delete shares on the local computer (WinNT/XP)'
Google
Advertise here!