[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
????
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
Re: [VB6] - instead api_doevents
Quote:
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;)
Re: [RESOLVED] [VB6] - instead api_doevents
Thanks Bonnie - that's very useful...
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