Page 1 of 1

Drawing on a non PB created window?

Posted: Sun Nov 05, 2006 11:37 am
by nicolaus
Hi

I have a Window wat is not crated bei PB and so i have only the handle but not the id of the Window.
How i can draw with the drawing functions from PB into this window?
You know for StartDrawing() we must set the WindowOutput() function with the ID of the window, but i don“t have the ID only the handle.

Thanks
Nico

Posted: Sun Nov 05, 2006 11:48 am
by lexvictory
windowid = hwnd

does that help?

Posted: Sun Nov 05, 2006 11:52 am
by DarkDragon

Code: Select all

!extrn _PB_2DDrawing_GlobalStructure

Procedure StartDrawingEx(hWindow)
  Protected hDC.l
  
  hDC = GetDC_(hWindow)
  
  !MOV EAX, [p.v_hDC]
  !MOV [_PB_2DDrawing_GlobalStructure], EAX
  
  ProcedureReturn 1
EndProcedure

Procedure StopDrawingEx(hWindow)
  Protected hDC.l
  
  hDC = 0
  
  !MOV EAX,[_PB_2DDrawing_GlobalStructure]
  !MOV [p.v_hDC], EAX
  
  ReleaseDC_(hWindow, hDC)
EndProcedure

OpenWindow(0, 0, 0, 640, 480, "Test")

Repeat
  StartDrawingEx(WindowID(0))
  Box(10, 10, 400, 300, RGB(255, 0, 0))
  LineXY(200, 100, 250, 300, RGB(255, 255, 0))
  StopDrawingEx(WindowID(0))
  Delay(10)
Until WindowEvent() = #PB_Event_CloseWindow
:shock: It works! I got a Assembler routine to work!

Posted: Sun Nov 05, 2006 1:55 pm
by SoulReaper
does not work here says assembler error... :?

Undefined symbols...

Good Job though :)

Posted: Sun Nov 05, 2006 2:03 pm
by lexvictory
works here, but im still using 4.0..

Posted: Sun Nov 05, 2006 2:10 pm
by DarkDragon
SoulReaper wrote:does not work here says assembler error... :?

Undefined symbols...

Good Job though :)
Turn threadsafe off. And visit this link: http://www.purebasic.fr/english/viewtop ... highlight=

Posted: Sun Nov 05, 2006 2:41 pm
by SoulReaper
oh i see never thought of that with threadsafe off :)