Problem w/ Inherited Forms .NET 2.0 CF

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?
 
M

ME

Turns out this issue is MUCH worse than I thought.

I have tried to write a "wrapper" class for the InputPanel but the issue is
much, much more difficult to get around (at least for me). It appears that
if the Reference to Microsoft.WindowsCE.Forms is used (even if only in a
declaration) ANYWHERE in your project (even if it is not in the base form)
you suddenly can lose visual inheritance!!!!

To recreate my problem please try this:

1) Create a new Compact Framework 2.0 Device Application (with one Form).
Add a button (Button1) on the existing form (Form1) in the new project.
2) Add a second Form to the project called Form2.
3) Make it inherit from From1
4) Build your project and then display Form2 in the designer. You should
see your inherited Button from From1.
5) Add a Reference to Microsoft.WindowsCE.Forms
6) Add a new Class (Class1) that simply declares the following:
Microsoft.WindowsCE.Forms.InputPanel ip;
7) Build your project again
8) Now try to view Form2 in the designer. It should now display the
message: "Visual inheritance is currently disabled because the base class
references a device-specific component or contains P/Invoke"

Using:
-Visual Studio 2005 Professional - ver 8.0.50727.42 (RTM.050727-4200)
-MS .NET Framework 2.0.50727


Now the real question: What good is inherited forms if you can't use the
INPUTPANEL in your project?! This is a real big problem for me, I don't
know about others but I really hope it gets fixed. I got to be able to see,
several inherited layers deep at times, the designer for inherited Forms.
Is this just my installation or this for everyone?

Thanks,

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top