I have now finished my "draw-to-desktop" code.
And here it is (This is updated code, so it should work):
Code: Select all
Global Memory
Memory = AllocateMemory(1024)
Procedure DesktopOutput()
PokeL(Memory, 1)
ProcedureReturn Memory
EndProcedure
StartDrawing(DesktopOutput())
Locate(130,100)
DrawText("See, you can draw to the desktop very easily.. to exit this program, press Escape on your keyboard.")
Ellipse(150,200,70,70,RGB(0,50,100))
Ellipse(350,200,70,70,RGB(0,50,100))
Ellipse(550,200,70,70,RGB(0,50,100))
Ellipse(750,200,70,70,RGB(0,50,100))
StopDrawing()
Repeat
Delay(5) ; Delay for CPU's health =D
If GetAsyncKeyState_(#VK_ESCAPE)
Quit = 1 ; If ESCAPE button is pushed, then quit.
EndIf
Until Quit
InvalidateRect_(0, 0, 0) ; Redraw the desktop.
End
And here is an example to draw a plot in the mouse position (made by request):
Code: Select all
Global Memory
Memory = AllocateMemory(1024)
If InitMouse() = 0
MessageRequester("Error", "Can't use mouse.", #MB_ICONERROR)
End
EndIf
Procedure DesktopOutput()
PokeL(Memory, 1)
ProcedureReturn Memory
EndProcedure
Repeat
ExamineMouse() ; Needed to update the MouseX() and MouseY() values.
StartDrawing(DesktopOutput())
Plot(DesktopMouseX(),DesktopMouseY(),RGB(0,50,100))
StopDrawing() ; As you see the drawing operations are inside the Repeat loop.
Delay(5) ; Delay for CPU's health =D
If GetAsyncKeyState_(#VK_ESCAPE)
Quit = 1 ; If ESCAPE button is pushed, then quit.
EndIf
Until Quit
InvalidateRect_(0, 0, 0) ; Redraw the desktop.
End