Hi,
I need simple example project (that works on all three platforms) where is canvas and horizontal scrollbar.
I’ve tryed to figure it out for my own now for a week and now i have to give up.
I need to draw several pictures and text to canvas.
I’ve tryed to draw it directly to canvas (growing canvas.width) and scrolling vanvas inside rectangle:
canvas.paint
[code] Canvas2.Width = 0
If data <> Nil Then
While Not data.EOF
if data.Field(“ktype”).IntegerValue < 5 then
Canvas2.Width = Canvas2.Width + 90
g.DrawString(CStr(data.Field(“kid”).IntegerValue), Canvas2.Width-70, 370)
g.DrawPicture(p(data.Field(“ktype”).IntegerValue -1), Canvas2.Width-86, 0)
else
Canvas2.Width = Canvas2.Width + 140
g.DrawString(CStr(data.Field(“kid”).IntegerValue), Canvas2.Width-120, 370)
g.DrawPicture(p(data.Field(“ktype”).IntegerValue -1), Canvas2.Width-136, 0)
end if
data.MoveNext
if Canvas2.Width > Rectangle2.Width then
ScrollBar1.Enabled=True
ScrollBar1.Maximum=Canvas2.Width-Rectangle2.Width
ScrollBar1.Minimum=0
Else
ScrollBar1.Enabled=False
End If
Wend
data.Close
End If[/code]
This won’t work at all in windows…
…and i’ve tryd to keep canvas still and moving only graphics:
If data <> Nil Then
While Not data.EOF
if data.Field("ktype").IntegerValue < 5 then
g.DrawString(CStr(data.Field("kid").IntegerValue), (leveys + 90)-70-ScrollBar1.Value, 370)
g.DrawPicture(p(data.Field("ktype").IntegerValue -1), (leveys + 90)-86-ScrollBar1.Value, 0)
leveys=leveys+90
else
g.DrawString(CStr(data.Field("kid").IntegerValue), (leveys + 140)-120-ScrollBar1.Value, 370)
g.DrawPicture(p(data.Field("ktype").IntegerValue -1), (leveys + 140)-136-ScrollBar1.Value, 0)
leveys=leveys+140
end if
data.MoveNext
if leveys > Canvas2.Width then
ScrollBar1.Enabled=True
ScrollBar1.Maximum=leveys-Canvas2.Width
ScrollBar1.Minimum=0
Else
ScrollBar1.Enabled=False
End If
Wend
data.Close
End If
This is closest I’ve get
I think I need to draw a buffer first, but if I draw in another method to buffer, buffer.graphics it’s always NilException.
So, please someone make simple example project, I couldn’t find anything from xojo examples.
Thanks
Jukka