473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Deriving from custom forms in C++, is it possible?

I know the answer to the question above is yes but my reason for
asking is that it doesn't seem to work properly

I have a manged C++ WinForms project
In it I have a form A, I want to derive a form B from it

Firstly the menu that the MSDN says should be available from the 'Add'
menu to 'Add an Inherited Form' isn't there
This seems to only be available for C# and VB.Net

Fine I can do it by hand, messy but not a big problem

I created form B and derived it from form A instead of
'System::Windows::Forms::Form'
Then I hit the second problem
This compiles and runs but I can't edit form B in the designer

Am I missing a step here or is it not possible to get the form
designer for inherited form in C++?

Vin
Nov 17 '05 #1
8 1318

For a real answer, we kinda need more info. IE, what do you mean by "Not
being able to edit the inherited form"?? What are you trying to edit??

Are you trying to edit the stuff (controls, menu bar, menu's) set up on the
first form?? almost everything in form A would be private, and so you
couldn't edit it in form b. Change them all to protected (Faster if you do
this by hand).

Next thing to check is namespaces. In order for form B to have any chance
of comming up in the form designer, it can only be wrapped inside of 1
namespace. IE namespace1::FormB is valid, Namespace1::SubNamespace1::FormB
will crash on you.

Can't think of anything else obvisous (can't spell either)..

GE

"Vincent Finn" wrote:
I know the answer to the question above is yes but my reason for
asking is that it doesn't seem to work properly

I have a manged C++ WinForms project
In it I have a form A, I want to derive a form B from it

Firstly the menu that the MSDN says should be available from the 'Add'
menu to 'Add an Inherited Form' isn't there
This seems to only be available for C# and VB.Net

Fine I can do it by hand, messy but not a big problem

I created form B and derived it from form A instead of
'System::Windows::Forms::Form'
Then I hit the second problem
This compiles and runs but I can't edit form B in the designer

Am I missing a step here or is it not possible to get the form
designer for inherited form in C++?

Vin

Nov 17 '05 #2
On Mon, 16 Aug 2004 17:09:01 -0700, Fireangel
<Fi*******@discussions.microsoft.com> wrote:

For a real answer, we kinda need more info. IE, what do you mean by "Not
being able to edit the inherited form"?? What are you trying to edit??
I mean that when I try to open the form in the Design window (by
double-clicking on the .h file) I get the following error

--------------
The designer could not be shown for this file because none of the
classes within it can be designed. The designer inspected the
following classes in the file:

B --- The base class 'Config.A' could not be loaded. Ensure
the assembly has been referenced or built if it is part of the
project.
--------------
Are you trying to edit the stuff (controls, menu bar, menu's) set up on the
first form?? almost everything in form A would be private, and so you
couldn't edit it in form b. Change them all to protected (Faster if you do
this by hand).
Don't get that far although that would have been a question later
since I noticed in C# that you don't get access to the events for
buttons that are on the base form in the derived form.
making them 'protected virtual' gives access although it is a bit
messy that you can't get to the handler by double-clicking, I assume
that'll be the same in C++
Next thing to check is namespaces. In order for form B to have any chance
of comming up in the form designer, it can only be wrapped inside of 1
namespace. IE namespace1::FormB is valid, Namespace1::SubNamespace1::FormB
will crash on you.


They are both in the Config namespace (that is the project name)
I tried using the 'Config::B' and simply 'B' but made no difference

Any other suggestions?

Vin
Nov 17 '05 #3

This is fireangel again, just at my work account..

The only other thing I can really think of is dealing with constructors. Do
you have any default constructors defined?? IE, FormA (void), FormB (void)??
In order for the form to be "designed" (Displayed really), a default
constructor must exist. I guess the reason for this is that the designer
can't come up with default values to pass to into the form, and so just gives
up.

Did you rename any of the namespaces, project name, or file names?? I've
had some issues with renaming some stuff and the compiler barfing on me from
it. Basically, for the project, there is a "Default Namespace" which (in
your case) has to be Config. When you go to compile the form, the compiler
takes the default namespace, then form name to name all the resources. IE,
if your the default namespace was test1, the resource file name for FormA
would be FormA.test1.resources. FormB would be looking for a file name of
FormA.Config.resources (You can see the slight diff), and formB would die in
loading...

If you still have problems, why don't you email what you have to fireangel1
AT comcast DOT net. Its my home account (i'm off the rest of the week)..

Hope it helps

GE

"Vincent Finn" wrote:
On Mon, 16 Aug 2004 17:09:01 -0700, Fireangel
<Fi*******@discussions.microsoft.com> wrote:

For a real answer, we kinda need more info. IE, what do you mean by "Not
being able to edit the inherited form"?? What are you trying to edit??


I mean that when I try to open the form in the Design window (by
double-clicking on the .h file) I get the following error

--------------
The designer could not be shown for this file because none of the
classes within it can be designed. The designer inspected the
following classes in the file:

B --- The base class 'Config.A' could not be loaded. Ensure
the assembly has been referenced or built if it is part of the
project.
--------------
Are you trying to edit the stuff (controls, menu bar, menu's) set up on the
first form?? almost everything in form A would be private, and so you
couldn't edit it in form b. Change them all to protected (Faster if you do
this by hand).


Don't get that far although that would have been a question later
since I noticed in C# that you don't get access to the events for
buttons that are on the base form in the derived form.
making them 'protected virtual' gives access although it is a bit
messy that you can't get to the handler by double-clicking, I assume
that'll be the same in C++
Next thing to check is namespaces. In order for form B to have any chance
of comming up in the form designer, it can only be wrapped inside of 1
namespace. IE namespace1::FormB is valid, Namespace1::SubNamespace1::FormB
will crash on you.


They are both in the Config namespace (that is the project name)
I tried using the 'Config::B' and simply 'B' but made no difference

Any other suggestions?

Vin

Nov 17 '05 #4

"Vincent Finn" <1@2.com> wrote in message
news:7n********************************@4ax.com...
I know the answer to the question above is yes but my reason for
asking is that it doesn't seem to work properly

I have a manged C++ WinForms project
In it I have a form A, I want to derive a form B from it


I've managed to derive from custom form after moving base class in a
separate assembly.
--
Vladimir Nesterovsky
e-mail: vl*******@multiconn.com
Nov 17 '05 #5
On Tue, 17 Aug 2004 04:27:01 -0700, Fireangel
<Fi*******@discussions.microsoft.com> wrote:

This is fireangel again, just at my work account..

The only other thing I can really think of is dealing with constructors. Do
you have any default constructors defined?? IE, FormA (void), FormB (void)??
In order for the form to be "designed" (Displayed really), a default
constructor must exist. I guess the reason for this is that the designer
can't come up with default values to pass to into the form, and so just gives
up.
The default constructor is there
Did you rename any of the namespaces, project name, or file names?? I've
had some issues with renaming some stuff and the compiler barfing on me from
it. Basically, for the project, there is a "Default Namespace" which (in
your case) has to be Config. When you go to compile the form, the compiler
takes the default namespace, then form name to name all the resources. IE,
if your the default namespace was test1, the resource file name for FormA
would be FormA.test1.resources. FormB would be looking for a file name of
FormA.Config.resources (You can see the slight diff), and formB would die in
loading...
I changed nothing except the base class

From a compile point of view it does work
It builds and runs and the inherited form display correctly
the problem is that i can't do anything with the form in the designer
If you still have problems, why don't you email what you have to fireangel1
AT comcast DOT net. Its my home account (i'm off the rest of the week)..


Thanks.
I'll cut it into a smaller project and send it to you.

Vin
Nov 17 '05 #6
On Tue, 17 Aug 2004 15:19:07 +0200, "Vladimir Nesterovsky"
<vl******@nesterovsky-bros.com> wrote:

"Vincent Finn" <1@2.com> wrote in message
news:7n********************************@4ax.com.. .
I know the answer to the question above is yes but my reason for
asking is that it doesn't seem to work properly

I have a manged C++ WinForms project
In it I have a form A, I want to derive a form B from it


I've managed to derive from custom form after moving base class in a
separate assembly.


That works for me too.
That is very odd, you'd think that it should be less likely to work
accross assemblies than in a single one!

Looks like a bug to me

Vin
Nov 17 '05 #7
I looked at your sample program, and the only way to get it to work is to use
diff namespaces. I'd say you definatally have a bug.

I went through all my projects that have multiple forms, and wouldn't you
know, everytime we had forms inherit, we had diff namespaces. What luck...

Sorry I couldn't help..

GE

"Vincent Finn" wrote:
I know the answer to the question above is yes but my reason for
asking is that it doesn't seem to work properly

I have a manged C++ WinForms project
In it I have a form A, I want to derive a form B from it

Firstly the menu that the MSDN says should be available from the 'Add'
menu to 'Add an Inherited Form' isn't there
This seems to only be available for C# and VB.Net

Fine I can do it by hand, messy but not a big problem

I created form B and derived it from form A instead of
'System::Windows::Forms::Form'
Then I hit the second problem
This compiles and runs but I can't edit form B in the designer

Am I missing a step here or is it not possible to get the form
designer for inherited form in C++?

Vin

Nov 17 '05 #8
On Tue, 17 Aug 2004 16:23:02 -0700, Fireangel
<Fi*******@discussions.microsoft.com> wrote:
I looked at your sample program, and the only way to get it to work is to use
diff namespaces. I'd say you definatally have a bug.

I went through all my projects that have multiple forms, and wouldn't you
know, everytime we had forms inherit, we had diff namespaces. What luck...

Sorry I couldn't help..


Oh well, at least I know I amn't going mad
and I can use Vladimir's work-around messy as it is

Thanks, Vin
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
5
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
9
by: Mark Olbert | last post by:
I'm reposting this in case it got lost... The ASPNET Configuration tool does not appear to be able to handle derived MembershipUser classes. Even the simplest possible derived class (one which...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
8
by: Jayme.Pechan | last post by:
Is it possible to allow derived forms to change the layout of the buttons and UI elements on a form? For example, I make Form1 with a button in the top left corner. I then make a Form2 that...
1
by: Christopher Pisz | last post by:
I set out to make a custom logger. Examining some other code laying around, I came across one that derived from ostream, and had a associated class derived from streambuf. Is this practice a good...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.