Code archives/Miscellaneous/BlitzMax Event Killer

This code has been declared by its author to be Public Domain code.

Download source code

BlitzMax Event Killer by SebHoll2006
SuperStrict compliant, this function may not appear necessary to a lot of people, but I've found many uses in my projects, such as removing double-posted events from the system event queue etc.

Example: KillEvent(EVENT_WINDOWMOVE)
Function KillEvent(pID%,pID2%=0)
		
		Local tmpList:TList = New TList
		
		PollSystem()
		
		tmpList.AddFirst CurrentEvent;PollEvent
		
		While EventID() <> Null
		
			If Not (EventID() = pID Or EventID() = pID2) Then tmpList.AddLast CurrentEvent		
		
			PollEvent()
		
		Wend
		
		For Local a:TEvent = EachIn tmpList
		
			PostEvent(a)
		
		Next
		
		PollEvent()
		
		tmpList.Clear()
		tmpList = Null

EndFunction

Comments

None.

Code Archives Forum