Results 1 to 4 of 4

Thread: Anyone tried the new DoEvents?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Anyone tried the new DoEvents?

    Does anyone know how to convert the Attribute?

    In a module:
    VB Code:
    1. Option Explicit On
    2. Imports System.Runtime.InteropServices
    3. 'Attribute VB_Name = "NewDoEvents"
    4.     <DllImport("user32", EntryPoint:="GetQueueStatus")> _
    5.     Private Shared Function GetQueueStatus(ByVal fuFlags As Int32) As Int32
    6.     End Function
    7.     ' API Constants and declare
    8.     ' Constants used by GetQueueStatus API function
    9.     Private Const QS_HOTKEY = &H80
    10.     Private Const QS_KEY = &H1
    11.     Private Const QS_MOUSEBUTTON = &H4
    12.     Private Const QS_MOUSEMOVE = &H2
    13.     Private Const QS_PAINT = &H20
    14.     Private Const QS_POSTMESSAGE = &H8
    15.     Private Const QS_SENDMESSAGE = &H40
    16.     Private Const QS_TIMER = &H10
    17.     Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
    18.     Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
    19.     Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY)
    20.     Private Const 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)
    21.     Private Const QS_MESSAGES = (QS_POSTMESSAGE Or QS_SENDMESSAGE)           ' Not MS standard constant
    22.     Private Const QS_STANDARD = (QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON Or QS_PAINT)   ' Not MS standard constant
    23.     ' Enumerator to determine what messages are watched
    24.     Public Enum QueueMessagesUsed
    25.         All_Inputs = QS_ALLINPUT
    26.         All_Events = QS_ALLEVENTS
    27.         Standard = QS_STANDARD
    28.         Messages = QS_MESSAGES
    29.         InputOnly = QS_INPUT
    30.         Mouse = QS_MOUSE
    31.         MouseMove = QS_MOUSEMOVE
    32.         Timer = QS_TIMER
    33.     End Enum
    34.     Private m_lQueueUsed As QueueMessagesUsed
    35.     Public Sub NewDoEvents()
    36.         ' you can choose what to wait on here, simply add constants for the events you wish to allow
    37.         m_lQueueUsed = QueueMessagesUsed.Standard + QueueMessagesUsed.Messages
    38.         ' only if those events you have specified are waiting in the que, then do them
    39.         If GetQueueStatus(m_lQueueUsed) <> 0 Then Application.DoEvents() ' or 'SendKeys.Flush()
    40.     End Sub

    This looks like it will work better than just DoEvents, or doing an Application.MessageLoop check.
    Last edited by TTn; Nov 8th, 2006 at 07:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width