Click to See Complete Forum and Search --> : Is it possible to derive Dialog ?
Le Sant Yves
May 11th, 1999, 04:26 AM
I am at the point where I have to design a main class an sub classes. The main class will contain members and will be virtual. I need to desing Dialog to manage members both for the main class and for sub classes. The way I know is to design only one Dialog that will check the sub class it receives in order to proper design it.
But I will prefer to desing one Dialog for the main class, that manages its members. And I intend to design Dialogs derived from the main one in which I will include the stuff to manage sub class's members.
Unfortunately I don't find any relevant information about how to do that in the help wild forest.
Is there any one that can answer:
+ is it possible to derive a Dialog ?
+ if yes, how to find how to do ?
Even the no response will help me !
Thanks.
Yves Le Sant
Metrology and Measurement Unit
Fundamental and Experimental Aerodynamics Departement
ONERA Meudon
(Office National d'Etudes et de Recherches Aérospatiales)
FRANCE
eric33
May 11th, 1999, 06:04 AM
Salut yves,
Je suis francais et je vais donc utiliser notre langage commun.
Oui tu peux dériver une CDialog. En fait je ne vois pas précisément le problème que tu poses.
La dérivation de la classe CDialog est un problème purement C++ :
class MyClass : public CDialog {
};
MyClass héritera de toutes les méthodes, propriétés et handlers de CDialog.
Si la réponse ne suffit pas essaye d'être plus précis dans ta question.
Salut.
Le Sant Yves
May 11th, 1999, 07:04 AM
High eric33,
1 Thanks for your french reply
2 I have to add more comments:
I know how to derive a CDialog, no problem. What I want:
+ assuming a base class Toto using 1 member m_toto1. I designed a dialog TotoDlg that will manage this member.
Toto will be a virtual class and the dialog will be rather rich, much more than a single CEdit box.
+ in the future, tomorrow morning !, I will derivate sub classes form Toto, as TotoSimple and TotoComplex. This 2 sub classes will have extra members that I will manage too. So I will design a dialog for both of them TotoSimpleDlg and TotoComplexDlg. The trick is that new members have to be managed together with m_toto1 (part of my base class Toto). And what I would like to do is to use what I have done for TotoDlg, that is to derivate TotoSimpleDlg and TotoComplexDlg from TotoDlg.
I hope that my question is now more understandable !!!
Thanks for reading thig ugly thing
Yves Le Sant
Metrology and Measurement Unit
Fundamental and Experimental Aerodynamics Departement
ONERA Meudon
(Office National d'Etudes et de Recherches Aérospatiales)
FRANCE
eric33
May 11th, 1999, 09:18 AM
Ok, jean
First I spoke in the first mail in french it is because I am french people and I thought you are too. But it seems i made a mistake. So lets go on with english.
When you speak about managing members are you talking about data exchange (DDX) ... ?
So if i understand your problem :
You have a main CDialog derived class with some DDX members
Then you want to derived this class to just add some others members and methods
By this method you will have a 'template' class that you may used for your childs derived classes.
I hope i understand the problem. I try something which works but it seems very easy so perhaps it is not what you are waiting for.
Hovewer here is the try :
1 ) First I create my base CDialog class
2 ) I make all DDX needed (members)
3 ) I change the constructor of the class so i can pass by the constructor the id of the window (important point if the derived classes do not use the same resource).
CBaseDialog::CBaseDialog(UINT id, CWnd* pParent)
: CDialog(id, pParent)
4 ) I create a child CDialog class but derived from CBaseDialog and not CDialog (all other stuff is the same except the name of the base class).
5 ) I create a new dialog resource with the same fields of the base dialog resource PLUS some others controls
6 ) I linked with the DDX the new controls to new members in the derived class
7 ) It works. For example UpdateData(TRUE) update all DDX members (the ones of the based class and the ones of the derived class).
Little note :
Because based class is CBaseDialog you have to implement defaut handler using this base class.
An example for PreTranslateMessage :
BOOL CDerivedDialog::PreTranslateMessage(MSG* pMsg)
{
// ...
// your code
// ...
return CBaseDialog::PreTranslateMessage(pMsg);
}
Note : if you correctly implement your derived class then the classwizard implements all based class's methods calls correctly.
To finish in this method the base class could be virtual or not. It is not important.
I think there are better ways to do for the same result. But i do not know one.
Hope this could help.
Le Sant Yves
May 12th, 1999, 03:22 AM
Dear french colleague,
You are right ! I am a really french guy, driking white and red wines, eating cheese, oisters and such ugly things. But I prefer to use my bad english because my question and your answer might help someone that doesn't speak our so nice language.
I performed your try and it works very well ! I had only to add a call to CBaseDialog::DoDataExchange in my CDerivedDialog::DoDataExchange method.
It is not exactly what I wanted, but finally it fits perfectly my requirements. So I will use this.
Thanks again eric33 for your effort.
A last word about what is easy and what is not: what is easy to do is what you know how to do. Now derivating a CDialog derived class is easy for me....
Yves Le Sant
Metrology and Measurement Unit
Fundamental and Experimental Aerodynamics Departement
ONERA Meudon
(Office National d'Etudes et de Recherches Aérospatiales)
FRANCE
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.