F
Florian Fordermaier
Hello,
I have the following problem:
I developed a control base class(derived from
System.Windows.Forms.Control) which adds
functionality needed by all derived controls(i.e. access to plc). If I
subclass this base class and drop the child on a form, the control
doesn't paint anymore. Instead, the type name of the control is
displayed as a string within this control.
This confused me a little, so I tried several things to figure out the
problem:
I created a new solution, added a device application and a device class
library.
In the class library I simply defined a class without any code in it:
public class MyControlBase : System.Windows.Forms.Control
{
}
I add a reference to the class library in my device application, derive
a control from my base class, like
public class MyControl : MyControlBase
{
public override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(Color.Red); // just to see if painting
works
}
}
This worked just fine.
So I made my "real" base class completly empty(i.e. commented all inner
code) so that it looked like the declaration of MyControlBase(see
above).(I also derived it only from Control and removed all interfaces
from the inheritance list)
Again, the control does not paint, but shows its type name as a string.
The only difference in my opinion between the project with the "real"
base class and my test base class is that I use non-CLS compatible
types(ushort/uint) within the assembly where the control base class is
declared. I need those in order to do some interop with native
code(e.g. semaphores/events/memorymapped files/...)
Could this be the cause for this confusing behaviour?
Please help.
Thanks in advance
Florian
I have the following problem:
I developed a control base class(derived from
System.Windows.Forms.Control) which adds
functionality needed by all derived controls(i.e. access to plc). If I
subclass this base class and drop the child on a form, the control
doesn't paint anymore. Instead, the type name of the control is
displayed as a string within this control.
This confused me a little, so I tried several things to figure out the
problem:
I created a new solution, added a device application and a device class
library.
In the class library I simply defined a class without any code in it:
public class MyControlBase : System.Windows.Forms.Control
{
}
I add a reference to the class library in my device application, derive
a control from my base class, like
public class MyControl : MyControlBase
{
public override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(Color.Red); // just to see if painting
works
}
}
This worked just fine.
So I made my "real" base class completly empty(i.e. commented all inner
code) so that it looked like the declaration of MyControlBase(see
above).(I also derived it only from Control and removed all interfaces
from the inheritance list)
Again, the control does not paint, but shows its type name as a string.
The only difference in my opinion between the project with the "real"
base class and my test base class is that I use non-CLS compatible
types(ushort/uint) within the assembly where the control base class is
declared. I need those in order to do some interop with native
code(e.g. semaphores/events/memorymapped files/...)
Could this be the cause for this confusing behaviour?
Please help.
Thanks in advance
Florian