Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » How to set the Constructor of a derived widget class?
How to set the Constructor of a derived widget class? [message #3648] Sun, 11 June 2006 20:19 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

Perhaps this problem regards C++ rather than U++. But with non widget class I have had no problem so far. So please forgive me if this question appear silly.

I've a widget class obtained using the designer. Now I need another widget that has the same appearence of the first one except one more button. I decided to use the C++ feature to declare a derived class and avoid to duplicate the code.
I've written some thing but the compiler, when arrive to the new derived class, begins to complain with the constructor of the original class. Well, to keep the things simple I post the code of a very simple app. The widget class is a window with a droplist. Please let me ask you to write one line of code in the constructor of the derived class in order to run its instance. I believe to be able later to modify and extend it.

Thanks a lot.
Luigi

#include <CtrlLib/CtrlLib.h>
#define LAYOUTFILE <droplist/editmask.lay> 
#include <CtrlCore/lay.h>

///////////////////////// class DropDlg //////////////////////
class DropDlg : public WithDropLayout<TopWindow> {
public:
    void testAction();
    typedef DropDlg CLASSNAME;
    DropDlg();
};

void DropDlg::testAction() 
{ 
	PromptOK( AsString( dl.GetIndex() ));  
};

DropDlg::DropDlg()
{ 
    CtrlLayout(*this, "");
    // "key"-"display value" 
    dl.Add(1,   "One");
    dl.Add(2,   "Two");
    dl.Add(3,   "Three");
    dl.Add(4,   "Four");
    dl.WhenAction = THISBACK(testAction); 
}
///////////////////// end class  DropDlg ////////////////////

/*********** new derived class from class DropDlg ******************/
class NewDropDlg : public DropDlg {
    typedef NewDropDlg CLASSNAME;
    NewDropDlg();	
};

NewDropDlg::NewDropDlg()
{ 
  // how to set the constructor of the
  // derived clas to avoid complain from the compiler?
  // please fill one line code!
}
/**************** end derived class ********************************/


void OpenDialog()
{ DropDlg a;
  a.Run();

// run an instance of NewDropDlg
//  NewDropDlg b;
//  b.Run();

}

GUI_APP_MAIN
{ 	TopWindow w;
	Button b;
		
	w.Add(b);
	b.SetLabel("button - testAction");
	b.SetPos(b.PosLeft(200, 250), b.PosTop(100, 30));	
	b.WhenAction=callback(OpenDialog);

	w.Run();
}


/// editmask.lay
LAYOUT(DropLayout, 280, 208)
ITEM(DropList, dl, LeftPosZ(92, 124).TopPosZ(88, 48))
END_LAYOUT

[Updated on: Sun, 11 June 2006 20:21]

Report message to a moderator

Re: How to set the Constructor of a derived widget class? [message #3650 is a reply to message #3648] Sun, 11 June 2006 21:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
I think there is missing "public:".

Also, constructor is not required - if there is nothing to construct, you can avoid it (it will get generated as empty function by compiler).

Mirek
Re: How to set the Constructor of a derived widget class? [message #3656 is a reply to message #3650] Sun, 11 June 2006 23:41 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Sun, 11 June 2006 21:04

I think there is missing "public:".

Also, constructor is not required - if there is nothing to construct, you can avoid it (it will get generated as empty function by compiler).

Mirek


You are right. Thank you.
Luigi
Previous Topic: How do I use WIndows Message pump timer?
Next Topic: FrameAddSize(Size& sz) really needed?
Goto Forum:
  


Current Time: Sun May 19 06:50:05 CEST 2024

Total time taken to generate the page: 0.00835 seconds