CreateGraphics not supporting
Hi all,
When i add these lines to my project
Dim myGraphics As Graphics
Dim myPen As Pen
myPen = New Pen(Color.Red)
myGraphics = Me.PictureBox1.CreateGraphics()
myGraphics.DrawLine(myPen, 10, 10, 50, 50)
it is working with VIRC5, but not on the real controller. It is throwing an exception "NOTSUPPORTEDEXECUTION". When will this be available? Is there an another way to draw or fill something on a Panel or PictureBox.
Thanks
Comments
-
What version of RW are you using? Is this the old-style FlexPendant(with HTR buttons on the back) or the new style (no HTR buttons on the back)?
There is a note in the FPSDK release notes about CF2.0, CreateGraphics and a NotSupportedException, its not clear to me exactly what they are trying to say.
We are using a variation on what you are doing to create a groupbox control, so I don't think you are trying to do something impossible. We don't use CreateGraphics, but get our reference to the graphics object by overriding the OnPaint event handler for our BaseClass (Panel control) and using the PaintEventArgs.
Russell Drown0 -
I'm running RW 5.07.01.1030 with the new-style flexpendant.
can you give me an example of "but get our reference to the graphics object by overriding the OnPaint event handler for our BaseClass (Panel control) and using the PaintEventArgs."?
thank you
0 -
It should have said "get a reference to the graphics object...", but what I was describing was to create a class that inherits from some other visual component, such as System.Windows.Forms.Panel.
Public Class MyPanel
Inherits System.Windows.Forms.Panel
You can then override the default OnPaint event handler, and add new behavior to control how the object is rendered. In VB, it would look like:
Protected Overrides Sub OnPaint(ByVal e As _ System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)'call the base class method first
'implement other drawing behavior
Dim myPen As Pen
myPen = New Pen(Color.Red)
'use the PaintEventArgs parameter e
e.Graphics.DrawLine(myPen, 10, 10, 50, 50)
'...
'add erro handling and disposal, etc.
End Sub
I have not tested this snippet, but it is very similar to what we do to draw a GroupBox control. The one caveat is that it has never been tried on the new style FP, but I would assume it works the same on both.
There is a help topic in VS 2005 Help called "Overriding the OnPaint method" that describes this further.
Russell Drown0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings