Define PM_REMOVE for 1 Type tMSG Field tMsg.hwnd as Handle Field tMsg.message as Integer Field tMsg.wParam as Integer Field tMsg.lParam as Integer Field tMsg.Time as DWORD Field tMsg.ptX as DWORD Field tMsg.ptY as DWORD End_Type // The PeekMessage function dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist). External_Function PeekMessage "PeekMessageA" user32.dll ; Handle lpMsg Handle hWnd Integer wMsgFilterMin Integer wMsgFilterMax Integer wRemoveMsg ; Returns Integer // The TranslateMessage function translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function. External_Function TranslateMessage "TranslateMessage" user32.dll ; Handle lpMsg ; Returns Integer // The DispatchMessage function dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function. External_Function DispatchMessage "DispatchMessageA" user32.dll ; Handle lpMsg ; Returns Integer Function ProcessMessage Returns Boolean Boolean bMessageFound bTemp Pointer lpMsg Integer iPendingMessage String sMsg ZeroType tMsg To sMsg GetAddress of sMsg To lpMsg Move (FALSE) To bMessageFound If (PeekMessage(lpMsg, 0, 0, 0, PM_REMOVE)) Begin GetBuff From sMsg at tMsg.message To iPendingMessage If (iPendingMessage = WM_PAINT) Begin Move (TRUE) To bMessageFound Move (TranslateMessage(lpMsg)) To bTemp Move (DispatchMessage(lpMsg)) To bTemp End End Function_Return bMessageFound End_Function Procedure ProcessMessages Boolean bMessageProcessed Move (TRUE) To bMessageProcessed While (bMessageProcessed) Get ProcessMessage To bMessageProcessed Loop End_Procedure