//TH-Header //***************************************************************************************** // Copyright (c) 2018 Your Company Name // All rights reserved. // // $FileName : MessageQueueHelpers.pkg // $ProjectName : The Hammer 3 // $Authors : // $Created : 02.08.2018 11:54 // // Contents: // Used for dispatching keys from the message queue. // //***************************************************************************************** //TH-RevisionStart // ******************** // MODIFICATION SUMMARY // ******************** // ####### DD/MM/YYYY WHO COMMENT //TH-RevisionEnd Define WM_HOTKEY For |CI$0312 // 0x0312 Define PM_REMOVE For 1 // dll-function and msg-type needed for removing posted messages from the message queue // 28.1.2003 BP 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 External_Function PeekMessage "PeekMessageA" user32.dll Pointer pMsg Handle hWnd Integer iMin Integer iMax Integer iRemove Returns Integer External_Function TranslateMessage "TranslateMessage" user32.dll Pointer pMsg Returns Integer External_Function DispatchMessage "DispatchMessageA" user32.dll Pointer pMsg Returns Integer // // Dispatches the next message in the queue if it is a hotkey // (a key that combined with the alt-keyboard key) // Procedure DispatchHotkey Integer iPendingMessage Integer iVoid iTranslated Pointer pMsg String sMsg ZeroType tMsg To sMsg GetAddress Of sMsg To pMsg If (PeekMessage(pMsg, 0, 0, 0, PM_REMOVE)) Begin GetBuff From sMsg At tMsg.message To iPendingMessage If (iPendingMessage = WM_HOTKEY) Begin Move (TranslateMessage(pMsg)) To iTranslated If (iTranslated) Begin Move (DispatchMessage(pMsg)) To iVoid End End End End_Procedure // // Dispatches ANY key press from the loop, not just one, but all of them // Procedure DispatchAnyKey Integer iPendingMessage Integer iVoid iTranslated Pointer pMsg String sMsg ZeroType tMsg To sMsg GetAddress Of sMsg To pMsg If (PeekMessage(pMsg, 0, 0, 0, PM_REMOVE)) Begin GetBuff From sMsg At tMsg.message To iPendingMessage If (iPendingMessage = WM_HOTKEY or iPendingMessage = WM_KEYDOWN or iPendingMessage = WM_KEYUP) Begin Move (TranslateMessage(pMsg)) To iTranslated If (iTranslated) Begin Move (DispatchMessage(pMsg)) To iVoid End End End End_Procedure