Page 1 of 2

Draw to the desktop =D

Posted: Mon Nov 28, 2005 8:11 pm
by josku_x
Hello people!

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
I made this for roachofdeath, but I see that it belongs here.

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
Have fun.

Posted: Mon Nov 28, 2005 9:06 pm
by GeoTrail
I get an error: Line 4 - Specified address is null

Code: Select all

 PokeL(Memory, 1) 

Posted: Mon Nov 28, 2005 9:10 pm
by rsts
GeoTrail wrote:I get an error: Line 4 - Specified address is null

Code: Select all

 PokeL(Memory, 1) 
I believe you have to make the variable global.

Posted: Tue Nov 29, 2005 1:45 pm
by josku_x
Maybe this works? (I updated the first post, so now it has the right code.)

Code: Select all

Global Memory
Memory = AllocateMemory(1024) 

;Procedure DesktopOutput() - Just incase you need this. 
;  PokeL(Memory, 1) 
;  ProcedureReturn Memory 
;EndProcedure 

StartDrawing(DesktopOutput()) 
; Drawing code goes here. 
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
It's as rsts said, I forgot to make the variable Global. thanks for reminding!

Posted: Tue Nov 29, 2005 2:52 pm
by GeoTrail
Works fine now ;)
Pretty funny, can use the draw mouse thing to scare people, you can say it's a virus or something :lol: And they must pay to get help removing it :twisted:

Posted: Tue Nov 29, 2005 3:04 pm
by dagcrack
:? :? :? What's the deal with this? Get codearchiv:

Code: Select all

; www.purearea.net (Sourcecode collection by cnesm)
; Author:  (updated for PB3.93 by ts-soft)
; Date: 22. November 2003

Global mem.l 
; hier werden 1024 byte speicher reserviert 
mem = AllocateMemory(1024) 

Procedure.l DesktopOutput() 
  PokeL(mem, 1) 
  ProcedureReturn mem 
EndProcedure 

Maus.POINT 

Repeat 
  ; hier werden die maus koordinaten ausgelesen 
  GetCursorPos_(Maus) 
  ; 
  ; hier beginnt die verwirrung 
  StartDrawing(DesktopOutput()) 
    Plot(Maus\x, Maus\y, $0000FF) 
  StopDrawing() 
  ; 
  ; delay für cpu entlastung 
  Delay(5) 
  ; hier wird die escape taste geprüft 
  If GetAsyncKeyState_(#VK_ESCAPE) 
    Quit = 1 
  EndIf 
  
Until Quit 
InvalidateRect_(0, 0, 0) 
End  
; jaPBe Version=2.5.4.22
; Build=0
; FirstLine=0
; CursorPosition=18
; ExecutableFormat=Windows
; DontSaveDeclare
; EOF
Rip off?

Posted: Tue Nov 29, 2005 5:21 pm
by josku_x
GeoTrail wrote:Works fine now ;)
Pretty funny, can use the draw mouse thing to scare people, you can say it's a virus or something :lol: And they must pay to get help removing it :twisted:
That's funny! I laughed for that about 10 minutes :lol: :D ...

dagcrack wrote: :? :? :? What's the deal with this? Get codearchiv:
well, dagcrack, maybe there is similar code to do that in the codearchiv, but that doesn't count! This counts here, because I needed a half-hour to do this, it was hard first to do the DesktopOutput procedure, and after it was completed I tried very much to do things right, because I was afraid something could happen to my PC. After I saw it kills my CPU, I wanted to stop working on it, but when it was just to use Delay(5), then the show began :) ... Also, while I was experimenting the Win32 API, I found the InvalidateRect_() procedure which refreshes the determined area.. So what I mean is, that I made much work to do this.

Code: Select all

PS: Updated code! Check the first code snippet in my first post. lol.

Posted: Tue Nov 29, 2005 6:06 pm
by GeoTrail
josku_x wrote:PS: Updated code! Check the first code snippet in my first post. lol.
If you add a message to be written on the desktop that says something like "Microsoft Windows XP Beta 1. Will expire in 2 days" you could also get a cheap laugh hehehe ;)

Posted: Tue Nov 29, 2005 6:08 pm
by thefool
GeoTrail wrote:
josku_x wrote:PS: Updated code! Check the first code snippet in my first post. lol.
If you add a message to be written on the desktop that says something like "Microsoft Windows XP Beta 1. Will expire in 2 days" you could also get a cheap laugh hehehe ;)
Guess what ill send you for xmas :twisted:

Posted: Tue Nov 29, 2005 6:12 pm
by GeoTrail
thefool wrote:Guess what ill send you for xmas :twisted:
Xbox 360? :lol:

Posted: Tue Nov 29, 2005 6:14 pm
by thefool
hah in your dreams :P

Posted: Tue Nov 29, 2005 6:19 pm
by GeoTrail
Ok ok, how about a PSP instead then? :P

Posted: Tue Nov 29, 2005 6:36 pm
by thefool
give me your adress and ill send a real nice letterbomb!

Posted: Tue Nov 29, 2005 8:25 pm
by GeoTrail
OK, but it's just gonna get stamped with Return to sender :lol:

Posted: Tue Nov 29, 2005 10:26 pm
by thefool
:lol: