DoEvents Evolution Revisited (Updated)
Posted: 2002-06-01
By: ArchiveBot
Viewed: 92
Filed Under:
Title | Uploaded | Size |
---|---|---|
DoEvents_E68736442002.zip | 9/3/2020 3:45:00 PM | 8,422 |
How to use John Galanopoulos' article in a class module to override the standard DoEvents method.
Original Author: JohnB
Code
Don't forget to destroy your object when you are through with it! (I chose this method name to "honor" John for his article.) Thanks and good luck!I added/changed some code to further optimize my code which basically is an
optimization of the DoEvents method. Thanks goes to Marzo
Sette Torres Junior for his help!
It is best to view the article located here: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=29735&lngWId=1
Next download the code attached, which is just a class module. I included the Word DOC file from John G. with the class module.
Simply add the module to your project and declare an object of the clsDoEvents type:
Dim oDoEvents as clsDoEvents
Set oDoEvents = New clsDoEvents
Then set its only property to any of the enumerated values.
oDoEvents.QueueUsed = Standard
Valid enumerated values for this property
All_Inputs = QS_ALLINPUT
All_Events = QS_ALLEVENTS
Standard = QS_STANDARD
Messages = QS_MESSAGES
InputOnly = QS_INPUT
Mouse = QS_MOUSE
MouseMove = QS_MOUSEMOVE
Timer = QS_TIMER
Constants relating to the above enumerated values:
QS_HOTKEY = &H80
QS_KEY = &H1
QS_MOUSEBUTTON = &H4
QS_MOUSEMOVE = &H2
QS_PAINT = &H20
QS_POSTMESSAGE = &H8
QS_SENDMESSAGE = &H40
QS_TIMER = &H10
QS_MOUSE = (QS_MOUSEMOVE Or
QS_MOUSEBUTTON)
QS_INPUT = (QS_MOUSE Or QS_KEY)
QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or _
QS_HOTKEY)
QS_ALLINPUT = (QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or QS_POSTMESSAGE Or _
QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)
QS_MESSAGES = (QS_POSTMESSAGE Or QS_SENDMESSAGE) ' Not MS standard constant
QS_STANDARD = (QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON Or QS_PAINT) ' Not MS standard constant
Now, in any long winded loop, simple call the only method:
oDoEvents.GetInputState
API function that will determine if we need to DoEvents:
Private Declare Function GetQueueStatus Lib "user32" (ByVal fuFlags As Long) As Long
Set oDoevents =
Nothing
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.