Using Win32 functions in Visual FoxPro Image Gallery
Message and Message Queue
..msdn
BroadcastSystemMessage
GetQueueStatus
MQCloseQueue
MQDeleteQueue
MQHandleToFormatName
MQOpenQueue
MQPathNameToFormatName
MQPurgeQueue
PeekMessage
PostMessage
PostQuitMessage
SendMessage
Code examples:
Simulating DOEVENTS
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: 33  
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-2018 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.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.227.17.101)
20 sec.Function: 'TextOut'
40 sec.Function: 'UpdateResource'
1.07 min.Function: 'CopyImage'
1.42 min.Function: 'CeRegEnumKeyEx'
Function group: 'Remote Application Programming (RAPI)'
1.78 min.Function: 'GetTcpStatistics'
2.13 min.Function: 'FindResource'
Function group: 'Resource'
2.48 min.Function: 'GetVolumeInformation'
2 day(s)Function: 'GetEnvironmentVariable'
Function group: 'Process and Thread'
 Function: 'CeRegQueryValueEx'
Function group: 'Remote Application Programming (RAPI)'
 Function: 'CryptReleaseContext'
Function group: 'Cryptography Reference'
Google
Advertise here!