Page 1 of 1

How get current DC?

Posted: Tue Aug 27, 2013 8:18 am
by sec

Code: Select all

Procedure IsDrawing()
  !extrn _PB_2DDrawing_CurrentDC
  !MOV eax, dword [_PB_2DDrawing_CurrentDC]
  ProcedureReturn
EndProcedure
I tried above code, but failed. How get current DC now?

Re: How get current DC?

Posted: Tue Aug 27, 2013 8:30 am
by Danilo
sec wrote:

Code: Select all

Procedure IsDrawing()
  !extrn _PB_2DDrawing_CurrentDC
  !MOV eax, dword [_PB_2DDrawing_CurrentDC]
  ProcedureReturn
EndProcedure
I tried above code, but failed. How get current DC now?

Code: Select all

Procedure StartDrawing_replacement(Output)
    Shared _PB_2DDrawing_CurrentDC
    _PB_2DDrawing_CurrentDC = StartDrawing(Output)
    ProcedureReturn _PB_2DDrawing_CurrentDC
EndProcedure

Procedure StopDrawing_replacement()
    Shared _PB_2DDrawing_CurrentDC
    _PB_2DDrawing_CurrentDC = 0
    StopDrawing()
EndProcedure

Macro StartDrawing(Output) : StartDrawing_replacement(Output) : EndMacro
Macro StopDrawing() : StopDrawing_replacement() : EndMacro

Procedure IsDrawing()
    Shared _PB_2DDrawing_CurrentDC
    ProcedureReturn _PB_2DDrawing_CurrentDC
EndProcedure



Debug IsDrawing()

If CreateImage(1,100,100)
    If StartDrawing(ImageOutput(1))
        Debug IsDrawing()
        StopDrawing()
        Debug IsDrawing()
    EndIf
EndIf

Re: How get current DC?

Posted: Tue Aug 27, 2013 8:43 am
by sec
Danilo wrote:
sec wrote:

Code: Select all

Procedure IsDrawing()
  !extrn _PB_2DDrawing_CurrentDC
  !MOV eax, dword [_PB_2DDrawing_CurrentDC]
  ProcedureReturn
EndProcedure
I tried above code, but failed. How get current DC now?

Code: Select all

Procedure StartDrawing_replacement(Output)
    Shared _PB_2DDrawing_CurrentDC
    _PB_2DDrawing_CurrentDC = StartDrawing(Output)
    ProcedureReturn _PB_2DDrawing_CurrentDC
EndProcedure

Procedure StopDrawing_replacement()
    Shared _PB_2DDrawing_CurrentDC
    _PB_2DDrawing_CurrentDC = 0
    StopDrawing()
EndProcedure

Macro StartDrawing(Output) : StartDrawing_replacement(Output) : EndMacro
Macro StopDrawing() : StopDrawing_replacement() : EndMacro

Procedure IsDrawing()
    Shared _PB_2DDrawing_CurrentDC
    ProcedureReturn _PB_2DDrawing_CurrentDC
EndProcedure



Debug IsDrawing()

If CreateImage(1,100,100)
    If StartDrawing(ImageOutput(1))
        Debug IsDrawing()
        StopDrawing()
        Debug IsDrawing()
    EndIf
EndIf
Thanks Danilo for code :D

Re: How get current DC?

Posted: Tue Aug 27, 2013 8:49 am
by Danilo
sec wrote:Thanks Danilo for code :D
Not as future compatible as the solution above:

Code: Select all

Procedure IsDrawing()
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
        !extern _PB_2DDrawing_Pointer
    CompilerElse
        !extrn _PB_2DDrawing_Pointer
    CompilerEndIf
    !MOV eax, dword [_PB_2DDrawing_Pointer]
    ProcedureReturn
EndProcedure

Debug IsDrawing()

If CreateImage(1,100,100)
    If StartDrawing(ImageOutput(1))
        Debug IsDrawing()
        StopDrawing()
        Debug IsDrawing()
    EndIf
EndIf

Re: How get current DC?

Posted: Tue Aug 27, 2013 9:10 am
by sec
Danilo wrote:
sec wrote:Thanks Danilo for code :D
Not as future compatible as the solution above:

Code: Select all

Procedure IsDrawing()
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
        !extern _PB_2DDrawing_Pointer
    CompilerElse
        !extrn _PB_2DDrawing_Pointer
    CompilerEndIf
    !MOV eax, dword [_PB_2DDrawing_Pointer]
    ProcedureReturn
EndProcedure

Debug IsDrawing()

If CreateImage(1,100,100)
    If StartDrawing(ImageOutput(1))
        Debug IsDrawing()
        StopDrawing()
        Debug IsDrawing()
    EndIf
EndIf
@Danilo: great, i have updated the code here: http://www.purebasic.fr/english/viewtop ... 58#p106258