I have an old Realbasic Project that I am converting to Xojo and am stuck with a custom control that keeps giving me a compile error as Follows:
Error:
SpeedBar.SetSpeedToX, line 11
Expected a value of type class Graphics, but found a static namespace reference to class Graphics.
Draw Graphics
What has changed in XoJo that would cause this code to not compile anymore?
Draw is a Methothod that creates the custom control which is a slider style control.
Draw is called from another Method called SetSpeedToX
Below are the two Methods:
Draw //First Method
Dim destg As Graphics
#if true
double-buffer
static p As Picture
if p is nil or p.Width < Width or p.Height < Height then p = New Picture(Width, Height, 32)
destg = g
g = p.Graphics
#endif
//g.ForeColor = Window.BackColor this sets the controls back color to back the background color I set it to black below.
g.ForeColor = &c000000
g.FillRect 0, 0, Width, Height
Dim midX As Integer = Width/2
g.TextFont = “System”
g.TextSize = 10
Dim y0 As Integer = 1
Dim y1 As Integer = Height - g.TextHeight
// Draw bar
if mSpeed > 0 then
g.ForeColor = kPosBarColor
g.FillRect midX+1, y0, (Width-midX)*(mSpeed/100), y1-y0
elseif mSpeed < 0 then
g.ForeColor = kNegBarColor
Dim w As Integer = (mSpeed/-100) * midX
g.FillRect midX - w, y0, w, y1-y0
end if
// Draw midline
g.ForeColor = &c808080
g.DrawLine midX, y0, midX, y1
// Draw text
Dim s As String = "Speed: " + Format( mSpeed, “-0” )
g.ForeColor = &cCCCCCC
g.DrawString s, midX - g.StringWidth(s)/2, Height - g.TextHeight + g.TextAscent
// Draw border
g.ForeColor = &c686868
g.DrawRect 0, 0, Width, Height
// Blit to screen
#if true
destg.DrawPicture p, 0, 0, Width, Height, 0, 0, Width, Height
#endif
SetSpeedToX //Second Method
Dim midX As Integer = Width/3
if X > midX then
mSpeed = 100 * (X - midX) / (Width - midX)
elseif X < midX then
mSpeed = -100 * (midX - X) / midX
else
mSpeed = 0
end if
Draw Graphics
ValueChanged true