-
Dec 16th, 2012, 01:04 PM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - instead api_doevents
can i let the events being used\activated without using:
Code:
Option Explicit
Private Const PM_REMOVE = &H1&
Private Type Msg
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
ptX As Long
ptY As Long
End Type
Private Declare Function TranslateMessage Lib "user32" (lpMsg As Msg) As Long
Private Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, _
ByVal hwnd As Long, _
ByVal wMsgFilterMin As Long, _
ByVal wMsgFilterMax As Long, _
ByVal wRemoveMsg As Long) As Long
Public Sub API_DoEvents(ByVal hwnd As Long)
Dim TMsg As Msg
Do While PeekMessage(TMsg, hwnd, 0&, 0&, PM_REMOVE)
TranslateMessage TMsg
DispatchMessage TMsg
Loop
End Sub
????
-
Dec 29th, 2012, 03:41 AM
#2
Re: [VB6] - instead api_doevents
This is functionally similar to DoEvents but it only yields to the OS when there is actually something to process.
Code:
Private Declare Function GetInputState Lib "user32.dll" () As Long
Private Declare Function GetQueueStatus Lib "user32.dll" (ByVal Flags As Long) As Long
'Yields execution only when a message has arrived so that the operating system can process other events.
Public Function DoEventsEx() As Integer
#Const Keyboard_and_Mouse_Messages_Only = False
Const QS_ALLINPUT = &H4FF&
#If Keyboard_and_Mouse_Messages_Only Then
If GetInputState Then DoEventsEx = DoEvents
'GetInputState returns TRUE (nonzero) if either a keyboard or mouse message is in the application's
'input queue. If the application must distinguish between a mouse and a keyboard message, GetInputState
'returns the value 2 for a keyboard and the value 1024 for a mouse message.
#Else
If GetQueueStatus(QS_ALLINPUT) And &HFFFF0000 Then DoEventsEx = DoEvents
'The high-order word of GetQueueStatus' return value indicates the types of messages currently in the
'queue. The low-order word indicates the types of messages that have been added to the queue and that
'are still in the queue since the last call to the GetQueueStatus, GetMessage, or PeekMessage function.
#End If
End Function
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Dec 29th, 2012, 06:22 AM
#3
Thread Starter
PowerPoster
Re: [VB6] - instead api_doevents
Originally Posted by Bonnie West
This is functionally similar to DoEvents but it only yields to the OS when there is actually something to process.
Code:
Private Declare Function GetInputState Lib "user32.dll" () As Long
Private Declare Function GetQueueStatus Lib "user32.dll" (ByVal Flags As Long) As Long
'Yields execution only when a message has arrived so that the operating system can process other events.
Public Function DoEventsEx() As Integer
#Const Keyboard_and_Mouse_Messages_Only = False
Const QS_ALLINPUT = &H4FF&
#If Keyboard_and_Mouse_Messages_Only Then
If GetInputState Then DoEventsEx = DoEvents
'GetInputState returns TRUE (nonzero) if either a keyboard or mouse message is in the application's
'input queue. If the application must distinguish between a mouse and a keyboard message, GetInputState
'returns the value 2 for a keyboard and the value 1024 for a mouse message.
#Else
If GetQueueStatus(QS_ALLINPUT) And &HFFFF0000 Then DoEventsEx = DoEvents
'The high-order word of GetQueueStatus' return value indicates the types of messages currently in the
'queue. The low-order word indicates the types of messages that have been added to the queue and that
'are still in the queue since the last call to the GetQueueStatus, GetMessage, or PeekMessage function.
#End If
End Function
thanks for all
-
Feb 2nd, 2013, 01:04 PM
#4
Re: [RESOLVED] [VB6] - instead api_doevents
Thanks Bonnie - that's very useful...
If you don't know where you're going, any road will take you there...
My VB6 love-children: Vee-Hive and Vee-Launcher
-
Oct 31st, 2019, 09:25 AM
#5
Re: [RESOLVED] [VB6] - instead api_doevents
sorry to resurrect this thread, but its actually important.
I did have a problem with flickering, the form would from time to time flicker from a mouse click,
i thought first that is was a form_paint or form_resize issue, but after a lot of testing I found out that the problem is DoEvents.
two different DoEvents alternatives:
the simple: If GetQueueStatus(&HFF&) Then DoEvents
and the one Bonnie West posted,
but both gave me this flickering (a black background color that from time to time would flicker for a short moment, like it was white for a millisecond)
using DoEvents would not cause this.
so, well, DoEvents fixed it, but the question is, Why would it flicker at all.
its like using the alternative DoEvents, would push in a queue messages and after a while would get released and cause a flicker.
-
Oct 31st, 2019, 02:47 PM
#6
Thread Starter
PowerPoster
Re: [RESOLVED] [VB6] - instead api_doevents
baka: normaly the flicker only happens when you draw, on form, 2 or more colors\figures(even with backcolor) at same time.
the best is draw everything in a bitmap memory and then draw all the image in form... these is the best way for avoid flickers
-
Oct 31st, 2019, 03:39 PM
#7
Re: [RESOLVED] [VB6] - instead api_doevents
Im suing direct2d and theres no bitmap memory there, and the entire picture is created in "memory" before rendered.
the problem is not that, but the doevents that causes something to flicker, not the rendering itself, but the form/picturebox do something.
using DoEvents will not cause this, only if using the API GetQueueStatus
thats the reason I posted.
something is wrong with GetQueueStatus.
-
Oct 31st, 2019, 03:47 PM
#8
Thread Starter
PowerPoster
Re: [RESOLVED] [VB6] - instead api_doevents
to be 100% honest, for now, i use C++ and not VB6. but i know about flickers, i said to you
but maybe the GetQueueStatus() is more slow than Do_Events()?
maybe is there another function more faster
Moderator: Evertytime that i post i get the error that i must wait 30 seconds before post again... but the post is applied
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
|