draw on windows desktop ?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plopzz.

Hi

i would like to know if there a way to draw on the windows screen ...
(i think i need to use API directly)

So i can't use the draw command (and sprites) on a windows screen ?

Thanks
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> i would like to know if there a way to draw on the windows screen ...

I don't think there's much point because a refresh of the Desktop will
wipe any drawing off. Most apps that "draw" to the Desktop, usually
as gags, just make a copy of it and draw on the copy.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plopzz.

Hi PB (1112 posts..wow :p)

I have see many little applications who make that (u can found many "christmas stuff" with many objects who move on the desktop in "real time", without any problem ... Last example i have see : some lemmings who move, jump, get up on windows in real time...

i try to found a solution with delphi and i look after if i can apply that to purebasic

Thanks PB.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> I have see many little applications who make that (u can found
> many "christmas stuff" with many objects who move on the desktop

Ah, okay. Those are most likely sprites or something. When you said
"draw" I thought you meant like with the 2D graphics commands, because
those would be erased with a Desktop refresh.

There's a Visual Basic example here...

http://www.vbcodemagician.dk/tips/gfx_d ... ontext.htm

...which would be easier to convert to PureBasic than Delphi, but I did
a test and sure enough, the drawing is lost when I pressed F5 to do a
refresh.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

This are skinned Windows that move around...

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

Code: Select all

Procedure DTDC(Text.s,x,y)tR.RECT
hdc = CreateDC_("DISPLAY", 0, 0, 0) 
If hdc
   tR\left = x 
   tR\top = y
   tR\right = x+(Len(text)*8) 
   tR\bottom = y+32 
   lCol = GetTextColor_(hdc) 
   SetTextColor_(hdc, $FF)
   DrawText_(hdc, Text, Len(Text), tR, 0 )
   SetTextColor_( hdc, lCol)
EndIf
EndProcedure

hWnd = OpenWindow(0, 100, 100, 100, 50,   #PB_Window_SystemMenu , "Test")
If hWnd
 CreateGadgetList(hWnd)
 ButtonGadget(0, 5, 5, 95, 32, "Press-Me")
 Repeat
  EventID = WaitWindowEvent()
  Select EventID
  Case  #PB_EventGadget      
   For i=1 To 200 Step 20
    DTDC("CodeGuru!",I,I)
   Next 
   beep_(100,20)
  Case #PB_EventCloseWindow
   Quit = 1
  EndSelect
 Until Quit
EndIf
End
Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by scurrier.

Rings you rock!!!!
you wouldn't happen to have an example with a sprite?

thanks
Sean
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

Originally posted by scurrier

Rings you rock!!!!
you wouldn't happen to have an example with a sprite?

thanks
Sean
if you want to use sprites (maybe transparent) it would be better if you copy (grab) the display and work with a Copy of them(Image).
There are no normal API-Commands for Sprites available.



Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Writing directly over the desktop should be forbidden :). What a mess !

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plopzz.

ok thanks all

fred : ok i promise :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.
Originally posted by fred

Writing directly over the desktop should be forbidden :). What a mess !

Fred - AlphaSND
LOL,
Fred, You like to catchup PB with double posts


Regards,

Benny

http://www.benny.zeb.be
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> LOL, Fred, You like to catchup PB with double posts

Grrr... :evil:


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Hehe, removed, but this one count too :).

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

See this small skinned Window Example:
(needs SkinWin Library installed: http://www.reelmediaproductions.com/pb/ ... nwin10.zip)

Code: Select all

;------------
Procedure OpenTextWindow(WinNumber, Text$, Color)
   FontName$ = "Arial Black"
   FontHeight = 48
   If FontRequester("Arial Black",72,0)
      FontName$  = SelectedFontName()
      FontHeight = SelectedFontSize()
   EndIf
   Font = LoadFont(1,FontName$,FontHeight)
   CreateImage(1,10,10)
   StartDrawing(ImageOutput())
      DrawingFont(Font)
      TextWidth = TextLength(Text$) + 1
   StopDrawing()
   hBitmap = CreateImage(1,TextWidth+1,FontHeight+50)
   StartDrawing(ImageOutput())
      Box(0,0,TextWidth+1,FontHeight+50,$AAAAAA)
      Locate(1,0)
      FrontColor($FF,$FF,$00)
      DrawingFont(Font)
      DrawingMode(1)
      DrawText(Text$)
   StopDrawing()
   CloseFont(1)
   hWnd = OpenWindow(WinNumber,10,10,TextWidth,FontHeight+50,#WS_POPUP|#PB_Window_Invisible,"")
   SkinWin(hWnd, hBitmap)
   SetWinBackgroundColor(hWnd, Color)
   While WindowEvent():Wend
   WinX = GetSystemMetrics_(#SM_CXSCREEN)/2-TextWidth/2
   SetWindowPos_(hWnd,#HWND_TOPMOST,WinX,0,0,0,#SWP_NOSIZE|#SWP_SHOWWINDOW)
   ;
   ; Scroll to Middle of Screen
   For a = 0 To GetSystemMetrics_(#SM_CYSCREEN)/2-(FontHeight+50)/2 Step 2
       starttime = TimeGetTime_()
       SetWindowPos_(hWnd,#HWND_TOPMOST,WinX,a,0,0,#SWP_NOSIZE)
       While WindowEvent():Wend
       While TimeGetTime_() - starttime  Quit


Thats -IMO- much better (cleaner) than drawing on the users´s Desktop..

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

It is not a good codingsytle to paint directly on the desktop, but if you have to do it you can do it (Good to know).There are more exciting things that can be done with PureBasic.......
remember... ItCanBeDone.....

Its a long way to the top if you wanna .....CodeGuru
Post Reply