Page 1 of 1
hDC, Brush etc.
Posted: Sun Apr 04, 2004 1:10 pm
by freedimension
Is there a way of getting the current hDC, Brush, Color etc. inside of StartDrawing ... StopDrawing.
As for the hDC, I know that StartDrawing returns this one, but I want to be independent of this function.
Posted: Sun Apr 04, 2004 1:18 pm
by freak
From the LibrarySDK:
_PB_2DDrawing_CurrentDC ; OS Current DC (HDC)
_PB_2DDrawing_CurrentColor ; Current RGB 24 color
_PB_2DDrawing_CurrentMode ; Current drawing mode (Set by DrawingMode())
_PB_2DDrawing_Brush ; Current brush (for flood fill), set by FrontColor() (HBRUSH)
_PB_2DDrawing_Pen ; Current pen (for outline color), set by FrontColor() (HPEN)
You should easily be able to access these with !extrn
Timo
Posted: Sun Apr 04, 2004 1:22 pm
by freedimension
Yes, found this one too, but I don't have the asm-skills, needed to do so.
Any chance of getting a lection on asm from a real FREAK

Posted: Sun Apr 04, 2004 1:52 pm
by freedimension
After all it wasn't that hard:
Code: Select all
Procedure GetHDC()
!EXTRN _PB_2DDrawing_CurrentDC
!MOV EAX, dword [_PB_2DDrawing_CurrentDC]
ProcedureReturn
EndProcedure
Thanx a lot
Posted: Sun Apr 04, 2004 2:08 pm
by freak
Code: Select all
CurrentDC.l
!extrn _PB_2DDrawing_CurrentDC
!mov eax, [_PB_2DDrawing_CurrentDC]
!mov [v_CurrentDC], eax
The current dc is now in CurrentDC.l
Note: this only works outside of a procedure or with global variables.
This one also works inside: needs InlineASM to be on:
Code: Select all
CurrentDC.l
!extrn _PB_2DDrawing_CurrentDC
MOV eax, [_PB_2DDrawing_CurrentDC]
MOV CurrentDC, eax
In both cases, the variable needs to be declared before being used from asm.
I like this solution best: a little procedure:
Code: Select all
Procedure GetCurrentDC()
!extrn _PB_2DDrawing_CurrentDC
!mov eax, [_PB_2DDrawing_CurrentDC]
ProcedureReturn
EndProcedure
This works the same with all those valued.
Timo
[edit]too slow...
[/edit]
Posted: Sun Apr 04, 2004 2:40 pm
by freedimension
freak wrote:
[edit]too slow...
[/edit]
No, you helped me a lot, really.
Especially because of this:
Code: Select all
This one also works inside: needs InlineASM to be on:
CurrentDC.l
!extrn _PB_2DDrawing_CurrentDC
MOV eax, [_PB_2DDrawing_CurrentDC]
MOV CurrentDC, eax
I tried to figure this one out but came to no conclusion.