[API]
POINTAPI
MSG
GetMessageA
GetMessageW
IsDialogMessageA
IsDialogMessageW
TranslateMessage
DispatchMessageA
DispatchMessageW
PostQuitMessage

[INCLUDE]
Unicode

[CODE]
Public Sub MessageLoopAccel(ByVal hWnd As Long)
  Dim xMsg As MSG
  Dim xLong1 As Long

  If IsUnicode Then
    xLong1 = GetMessageW(xMsg, 0&, 0&, 0&)
    Do Until (xLong1 = 0&)
      If xLong1 = -1& Then
        ' handle the error and possibly exit
        ElseIf IsDialogMessageW(hWnd, xMsg) = 0& Then
        Call TranslateMessage(xMsg)
        Call DispatchMessageW(xMsg)
        End If
      xLong1 = GetMessageW(xMsg, 0&, 0&, 0&)
      Loop
    Else
    xLong1 = GetMessageA(xMsg, 0&, 0&, 0&)
    Do Until (xLong1 = 0&)
      If xLong1 = -1& Then
        ' handle the error and possibly exit
        ElseIf IsDialogMessageA(hWnd, xMsg) = 0& Then
        Call TranslateMessage(xMsg)
        Call DispatchMessageA(xMsg)
        End If
      xLong1 = GetMessageA(xMsg, 0&, 0&, 0&)
      Loop
    End If
  End Sub