Search Tools Links Login

DoEvents Evolution Revisited (Updated)


Visual Basic 6, or VB Classic

How to use John Galanopoulos' article in a class module to override the standard DoEvents method.

Original Author: JohnB

Code

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


Don't forget to destroy your object when you are through with it!

  Set oDoevents =
Nothing


(I chose this method name to "honor" John for his article.)


Thanks and good luck!


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 126 times

Categories

Visual Basic 6

Attachments

DoEvents_E68736442002.zip
Posted: 9/3/2020 3:45:00 PM
Size: 8,422 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.