Results 1 to 4 of 4

Thread: Anyone tried the new DoEvents?

  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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Anyone tried the new DoEvents?

    You should use the DllImport attrib too for the API declaration.

    VB Code:
    1. Imports System.Runtime.InteropServices
    2. 'and
    3.  
    4. <DllImport("user32", EntryPoint:="GetQueueStatus")> _
    5. Private Shared Function GetQueueStatus (ByVal fuFlags As Int32) As Int32
    6. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Anyone tried the new DoEvents?

    I think it doesnt convert as the code is originally VB 6 code from the .frm code behind which uses this "Atribute" property. It comes from the form name.

    Attribute VB_Name = "NewDoEvents"

    As viewed in Notepad/Wordpad:

    Code:
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   3090
       ClientLeft      =   60
       ClientTop       =   450
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3090
       ScaleWidth      =   4680
       StartUpPosition =   3  'Windows Default
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    
    Private Sub Form_Load()
        MsgBox "Hello World"
    End Sub
    Last edited by RobDog888; Nov 9th, 2006 at 02:35 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

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

    Re: Anyone tried the new DoEvents?

    Thanks again RobDogg!

    So that's it then.

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