At first I thought that Graphics.DrawPicture had been depreciated for g.DrawPicture.
After testing both I realised that they both act differently. Graphics.DrawPicture moves the canvas point of origin relative to the window, whereas g.DrawPicture moves the picture within the canvas at the point of origin. The LR on Graphics.DrawPicture uses examples that use g.DrawPicture - which is very confusing to me.
Nevertheless, what I’m trying to achieve is to draw a simple XY graph. It’s a MUST that the graph can be cropped/scaled/zoomed. I’ll be using DrawLine.
At the moment I’ve got the basics together. I’ve used this pseudo code that was posted on this forum (Paul Lefebvre) but adjusted to suit my purposes:
[code]Add a Picture as a property to WindowMain:
GraphPicture As Picture
Add a Canvas to the Window: (cnvGRAPH)
In the Canvas Open event handler, initialize the Picture: (X, Y, Colour depth)
GraphPicture = New Picture(600, 500, 32)
In the Paint Event handler of the Canvas, draw the Picture: (Picture Name, Origin X, Y)
g.DrawPicture (GraphPicture, 0, 0)
Create a Method to draw to the Picture. When the Canvas refreshes, it will then draw what you have in the Picture.
Example:
Method: DrawGraph
GraphPicture.Graphics.ForeColor = &c0000ff
GraphPicture.Graphics.FillRect(10, 10, 50, 50)
// Tell the canvas it needs to be updated, which
// calls its Paint event handler.
cnvGRAPH.Invalidate
Now call this method from something like a PushButton:
DrawGraph[/code]
This appears to work fine. I haven’t tried any scaling yet because I’m still unsure which way to go or what the potential issues might be if I stick with the above method.