Drawing on a non PB created window?

Just starting out? Need help? Post your questions and find answers here.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Drawing on a non PB created window?

Post 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
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

windowid = hwnd

does that help?
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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!
bye,
Daniel
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Post by SoulReaper »

does not work here says assembler error... :?

Undefined symbols...

Good Job though :)
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

works here, but im still using 4.0..
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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=
bye,
Daniel
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Post by SoulReaper »

oh i see never thought of that with threadsafe off :)
Post Reply