[RESOLVED] [VB6] - instead api_doevents-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] [VB6] - instead api_doevents

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    2,922

    Resolved [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
    ????
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    3,159

    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)

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    2,922

    Re: [VB6] - instead api_doevents

    Quote Originally Posted by Bonnie West View Post
    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    Fanatic Member
    Join Date
    Apr 2012
    Posts
    619

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.