|
-
Nov 8th, 2006, 06:50 PM
#1
Thread Starter
Fanatic Member
Anyone tried the new DoEvents?
Does anyone know how to convert the Attribute?
In a module:
VB Code:
Option Explicit On
Imports System.Runtime.InteropServices
'Attribute VB_Name = "NewDoEvents"
<DllImport("user32", EntryPoint:="GetQueueStatus")> _
Private Shared Function GetQueueStatus(ByVal fuFlags As Int32) As Int32
End Function
' API Constants and declare
' Constants used by GetQueueStatus API function
Private Const QS_HOTKEY = &H80
Private Const QS_KEY = &H1
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_MOUSEMOVE = &H2
Private Const QS_PAINT = &H20
Private Const QS_POSTMESSAGE = &H8
Private Const QS_SENDMESSAGE = &H40
Private Const QS_TIMER = &H10
Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY)
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)
Private Const QS_MESSAGES = (QS_POSTMESSAGE Or QS_SENDMESSAGE) ' Not MS standard constant
Private Const QS_STANDARD = (QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON Or QS_PAINT) ' Not MS standard constant
' Enumerator to determine what messages are watched
Public Enum QueueMessagesUsed
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
End Enum
Private m_lQueueUsed As QueueMessagesUsed
Public Sub NewDoEvents()
' you can choose what to wait on here, simply add constants for the events you wish to allow
m_lQueueUsed = QueueMessagesUsed.Standard + QueueMessagesUsed.Messages
' only if those events you have specified are waiting in the que, then do them
If GetQueueStatus(m_lQueueUsed) <> 0 Then Application.DoEvents() ' or 'SendKeys.Flush()
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.
-
Nov 8th, 2006, 06:54 PM
#2
Re: Anyone tried the new DoEvents?
You should use the DllImport attrib too for the API declaration.
VB Code:
Imports System.Runtime.InteropServices
'and
<DllImport("user32", EntryPoint:="GetQueueStatus")> _
Private Shared Function GetQueueStatus (ByVal fuFlags As Int32) As Int32
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Nov 9th, 2006, 02:31 AM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Nov 9th, 2006, 07:14 AM
#4
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|