M
ME
I playing around with Inherited Forms in .NET 2.0 Compact Framework and have
found a problem that I would like more clarification on.
Example:
I started with a generic DeviceApplication with a single form - Form1. I
added a button to it and then added a second form - Form2. I made Form2
derive from Form1 - (public partial class Form2 : Form1 ). This actually
worked with no issues. I could then design and modify as expected. The
problem arose when I added an Input Panel
(Microsoft.WindowsCE.Forms.InputPanel) to the base form (Form1). Now when I
look at Form2 to design it I get this displayed in GUI window: "Visual
inheritance is currently disabled because the base class references a
device-specific component or contains P/Invoke".
Problems:
This presents a few of problems.
1) I would like to add an Input Panel to my base form so I have a
standard object throughout my application, virtually all forms I will be
creating will need an Input Panel, so the need for it in the base class is
justified. In addition to this I need the BaseForm to expose the InputPanel
in a public property defined in an interface.
2) Even though the "Error" message is displayed on Form2 it still allows
one to add controls to it so it almost doesn't matter. The only time this
will matter is if you add a control, say a button, to the Base Class and use
the default name "Button1". When you a second button to Form2 it does not
know that the base form has "Button1" and so it creates a button as
"Button1" as well. (this does not occur if I remove the Input Panel from
the base form). Though I would never want a "Button1" on my form the same
principle would apply if you had two buttons with the same name (say someone
else inherits the form in their class and has no idea you named your button
xyz).
3) The component doesn't even have to be initialized, just simply declared
in the base form and the problem shows up. So the declaration "private
Microsoft.WindowsCE.Forms.InputPanel ip;" in the base form will cause the
issue regardless of what is in the InitializeComponent() method. This makes
it killer to work around if you happen to expose the object in a property.
I am not sure what the best approach would be in designing around this
issue, if any at all. Ultimately I would just like to use an inherited form
like the Full Framework can. I would be ok with a Conditional Compilation
Constant that could be "uncommented" when I needed to design. The trouble
with this idea is that I need to expose the InputPanel in a property.
What constitutes a component as "device-specific"? Does the Input Panel use
P/Invoke? Is it really P/Invoke that is causing the issue?
found a problem that I would like more clarification on.
Example:
I started with a generic DeviceApplication with a single form - Form1. I
added a button to it and then added a second form - Form2. I made Form2
derive from Form1 - (public partial class Form2 : Form1 ). This actually
worked with no issues. I could then design and modify as expected. The
problem arose when I added an Input Panel
(Microsoft.WindowsCE.Forms.InputPanel) to the base form (Form1). Now when I
look at Form2 to design it I get this displayed in GUI window: "Visual
inheritance is currently disabled because the base class references a
device-specific component or contains P/Invoke".
Problems:
This presents a few of problems.
1) I would like to add an Input Panel to my base form so I have a
standard object throughout my application, virtually all forms I will be
creating will need an Input Panel, so the need for it in the base class is
justified. In addition to this I need the BaseForm to expose the InputPanel
in a public property defined in an interface.
2) Even though the "Error" message is displayed on Form2 it still allows
one to add controls to it so it almost doesn't matter. The only time this
will matter is if you add a control, say a button, to the Base Class and use
the default name "Button1". When you a second button to Form2 it does not
know that the base form has "Button1" and so it creates a button as
"Button1" as well. (this does not occur if I remove the Input Panel from
the base form). Though I would never want a "Button1" on my form the same
principle would apply if you had two buttons with the same name (say someone
else inherits the form in their class and has no idea you named your button
xyz).
3) The component doesn't even have to be initialized, just simply declared
in the base form and the problem shows up. So the declaration "private
Microsoft.WindowsCE.Forms.InputPanel ip;" in the base form will cause the
issue regardless of what is in the InitializeComponent() method. This makes
it killer to work around if you happen to expose the object in a property.
I am not sure what the best approach would be in designing around this
issue, if any at all. Ultimately I would just like to use an inherited form
like the Full Framework can. I would be ok with a Conditional Compilation
Constant that could be "uncommented" when I needed to design. The trouble
with this idea is that I need to expose the InputPanel in a property.
What constitutes a component as "device-specific"? Does the Input Panel use
P/Invoke? Is it really P/Invoke that is causing the issue?