If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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&HFFFF0000Then 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

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&HFFFF0000Then 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

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.

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

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.

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