Confused about the state of GDIPlus vs Windows vs Xojo
I have some code the uses these Windows Declares…
Are they still going to work for the foreseeable future?
Has the DLL that supports them been deprecated and I need a replacement?
I don’t want to waste time programming around this snippet if I should be using something “newer”
// ************************** //
// ** Windows Pattern Line ** //
// ************************** //
Dim pen As Integer
Dim n As Integer
Dim c As Color
Dim gpx As Integer
Dim mb As New MemoryBlock(4)
Declare Function GdipCreatePen1 Lib "GDIPlus" (c As Integer, width As Single, unit As Integer, ByRef p As Integer) As Integer
Declare Function GdipSetPenDashStyle Lib "GDIPlus" (pen As Integer, style As Integer) As Integer
Declare Function GdipCreateFromHDC Lib "GDIPlus" (hdc As Integer, ByRef g As Integer) As Integer
Declare Function GdipDrawLine Lib "GDIPlus" (g As Integer, pen As Integer, x1 As Single, y1 As Single, x2 As Single, y2 As Single) As Integer
Declare Function GdipDeletePen Lib "GDIPlus" (pen As Integer) As Integer
Declare Function GdipDeleteGraphics Lib "GDIPlus" (g As Integer) As Integer
c = g.ForeColor
mb.Byte(0) = c.blue
mb.Byte(1) = c.green
mb.Byte(2) = c.red
mb.Byte(3) = 255 // alpha = opaque
n = mb.Int32Value(0)
Call GdipCreatePen1(n, g.PenWidth, 2, pen)
Call GdipSetPenDashStyle(pen, pattern)
Call GdipCreateFromHDC(g.handle(Graphics.HandleTypeHDC), gpx)
Call GdipDrawLine(gpx, pen, x1, y1, x2, y2)
Call GdipDeletePen(pen)
Call GdipDeleteGraphics(gpx)
Well for now 2016r4.1
but I wish to plan for the future… so I guess you are saying that those Declares are not “future proof” (not that any really are)
[quote=338523:@Dave S]Confused about the state of GDIPlus vs Windows vs Xojo
I have some code the uses these Windows Declares…
Are they still going to work for the foreseeable future?
Has the DLL that supports them been deprecated and I need a replacement?
I don’t want to waste time programming around this snippet if I should be using something “newer”[/quote]
Fortunately, using declares has nothing to do with the framework or what route Xojo take, those calls should be in windows forever. As long as you can get a HDC from Xojo, you will be fine.
If you are interested in going the D2D route, here’s a comparison between drawing with GDI and D2D.