Playing around with something here, I want to take a “screenshot” of a container control and copy it to a picture object.
Thinking along the lines of using containercontrol.drawinto to populate a graphics object with the image then try to convert the graphics object into a picture - somehow! Not really sure if this is really possible or best practice…
Create a ContainerControl and add the paint event:
Sub Paint(g As Graphics, areas() As REALbasic.Rect)
g.ForeColor = RGB(0, 151, 255)
g.DrawOval(0, 0, g.Width, g.Height)
End Sub
Put an instance of ContainerControl1 onto Window1.
In some event of Window1 (for example Close) put this code:
Dim pic As New Picture(ContainerControl1.Width, ContainerControl1.Height, 32)
ContainerControl1.DrawInto(pic.Graphics, 0, 0)
BREAK
Now when you close the window, you can click on the pic instance in the debugger and check its content (a blue circle).
When working with an array of containers I get an error on the following code
[code]Sub Constructor(Containers() As ContainerControl)
// We need to build the container all through code!
For i As Integer = 0 To Containers.Ubound
Dim pic As New Picture (Containers(i).Width, Containers(i).Height)
Dim gr As Graphics
End Sub
[/code]
I get the following message on the DrawInto statement - lots of playing around hasn’t sorted it unfortunately.
The method is protected. It can only be called from within its class
Tried outside the constructor and all sorts. Could one of the Xojo bods tell me if this is a bug or if I’m missing something? Couldn’t find anything in Feedback
You cannot use DrawInto outside of the container control itself, or the window instance owning the container control instance, or another control in the window owning the container control instance.