How get current DC?

Just starting out? Need help? Post your questions and find answers here.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

How get current DC?

Post 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?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: How get current DC?

Post 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
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: How get current DC?

Post 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
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: How get current DC?

Post 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
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: How get current DC?

Post 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
Post Reply