Xojo Developer Conference
Join us from 25th to 27th April 2018 in Denver.

Platforms to show: All Mac Windows Linux Cross-Platform

FAQ.How to draw with CGContextMBS using my own handle?
Feedback.

Answer: You can try this code:
Example:
Soft Declare Function QDBeginCGContext Lib "Carbon" (port as Integer, ByRef contextHandle as Integer) as Integer
dim contextRef as Integer
call QDBeginCGContext(g.handle(graphics.HandleTypeCGrafPtr), contextRef)
dim c as new CGContextMBS(contextRef)

c.BeginPath
c.SetLineWidth(3)
c.SetRGBFillColor(1,0,0,0.5)
c.FillRect(CGMakeRectMBS(0,0,100,100))
c.DrawPath(c.kCGPathFillStroke)
c.Flush // and so on

Soft Declare Function QDEndCGContext Lib "Carbon" (port as Integer, ByRef contextHandle as Integer) as Integer
dim h as Integer = c.Handle
call QDEndCGContext(g.handle(graphics.HandleTypeCGrafPtr), h)
c.Handle=0
Notes: Basicly you can provide your own handle to CGContextMBS. But if you do not set it back to 0 the CGContextMBS destructor will release the handle which can result into a crash. (if the reference count is wrong)




Links
MBS Xojo Chart Plugins