RobertF
(RobertF)
1
Hello everyone,
A property in a window as a graphics used to work but now fails.
Window_Report
Properties
g as graphics
…
Window_Report.g would give a NilObjectException.
Looks like that g was constructed automatically for the window before, but no longer now.
Any ideas?
Thanks!
g
is available in the window’s Paint
event.
RobertF
(RobertF)
3
Thank you. Will check Paint event.
RobertF
(RobertF)
4
If the graphics (Window_Report.g) needs to be manipulated / setup before Paint?
For example, Window_Report.g.foreColor (or DrawingColor) = 0xCFFFFFF
would give the exception.
Trying to construct a local graphics initially with
dim gLocal as new Graphics
would give this error at compile time:
The constructor of this class is protected, and can only be called from within this class
dim gLocal as new Graphics // Testing graphics.
Greg_O
(Greg O)
5
If you want to set something up outside of the paint event, make a property for holding a picture:
Private mBack as Picture
And then you can initialize that in the Opening event:
mBack = Self.BitmapForCaching(self.width, self.height)
Dim g as Graphics = mBack.graphics
// do your drawing here
Then in the Paint event:
If mBack <> nil then
g.drawPicture mBack,0,0
End If
RobertF
(RobertF)
6
Thank you, Greg O! Will make this change.