Working with API and TextOut

BlitzMax Forums/BlitzMax Programming/Working with API and TextOut

Hehe...BMax can do the string conversion for you (without the memory leak too)...
SuperStrict

Extern "win32"
	Function GetAsyncKeyState:Int(key:Int)
	Function GetWindowDC(hwnd:Int)
	Function GetForegroundWindow:Int()
	Function TextOutA:Int(dc:Int, x:Int, y:Int, txt$z, l:Int)
End Extern

Global CurrentDC:Int

SeedRnd MilliSecs()

Repeat
	CurrentDC=GetWindowDC(GetForegroundWindow())
	DrawTextOut("APPLES", Rand(800), Rand(600))
	Delay 30
Forever

Function DrawTextOut(Txt:String,X:Int,Y:Int)
	If CurrentDC<>0
		Print TextOutA(CurrentDC, X, Y, Txt, Txt.length)
	EndIf
End Function