Page 1 of 1

Deriving class from IGUIWindow

Posted: Fri Jan 06, 2006 2:23 pm
by miko93
Sirs,

I'm on to deriving my own class from IGUIWindow, trying to do it similar to the tutorial3 (http://irrlicht.sourceforge.net/tut003.html). My class so far looks like this:

Code: Select all

// infowindow.h

#pragma once

class CInfoWindow: public irr::gui::IGUIWindow
{
public:
	CInfoWindow(irr::gui::IGUIEnvironment *env, irr::s32 id, irr::core::rect<irr::s32> rec);
	~CInfoWindow(void);

	virtual irr::gui::IGUIButton* getCloseButton(void);
	virtual irr::gui::IGUIButton* getMinimizeButton(void);
	virtual irr::gui::IGUIButton* getMaximizeButton(void);
};

Code: Select all

// infowindow.cpp

#include "globals.h"

CInfoWindow::CInfoWindow(irr::gui::IGUIEnvironment *env, 
						 irr::s32 id, irr::core::rect<irr::s32> rec):
						 irr::gui::IGUIWindow(env, env->getRootGUIElement(), id, rec)
{}

CInfoWindow::~CInfoWindow(void)
{}

irr::gui::IGUIButton* CInfoWindow::getCloseButton(void)
{return(irr::gui::IGUIWindow::getCloseButton());}

irr::gui::IGUIButton* CInfoWindow::getMinimizeButton(void)
{return(irr::gui::IGUIWindow::getMinimizeButton());}

irr::gui::IGUIButton* CInfoWindow::getMaximizeButton(void)
{return(irr::gui::IGUIWindow::getMaximizeButton());}
Sadly enough, I get a linker error for the irr::gui::IGUIWindow::... routines (getCloseButton, getMinimizeButton, getMaximizeButton) like this
infowindow.obj : error LNK2019: Not resolved external symbol '"public: virtual class irr::gui::IGUIButton * __thiscall irr::gui::IGUIWindow::getCloseButton(void)" ...
I understand I'm missing something here (well, maybe missing the concept completely). Someone to enlighten me? Thank you very much.

miko

Posted: Sat Jan 07, 2006 6:51 am
by AshmenGlue
Maybe I could be wrong but you could try including the header file to IGUIButton since if I'm not wrong, the error apparently is cause there is some linking problem with this line :

virtual irr::gui::IGUIButton* getCloseButton(void);

Posted: Sun Jan 08, 2006 11:01 am
by bearSoft
is this std cpp....??
then, In any prototype u do not use the syntax
...........(void);
void is reserved for -returns- of 'nothing' eg

Code: Select all

void myFunc(int ii){
 GlobalVar=MYKONS+ii;
} 
saying that 'myFunc' is an 'internal calculation thingie' that does not -return- anything but it recieves the -argument- ii as the formal parameter. (the function is rubbish..)

In ur case it should simply be
~CInfoWindow(); //nothing in the paranteese
Saying that this does not take any -arguments-

Yesterday i linked to several c++ tut sites -u may like to look at those[/code]

Posted: Mon Jan 09, 2006 1:06 am
by Dark Rain
Things like "CInfoWindow(void)" are generated by default by ide like MSVS 2005 now. I too wasn't certain it was standard C++ at first but then it's true that int main(void) is something I used to see very often in C++ tutorials back in the days. I digged a bit further and the C++ reference says it's valid from the way I read it :
Void can also be used to declare an empty parameter list.
C++ reference url : http://www.cppreference.com/keywords/void.html

Posted: Thu Jan 12, 2006 7:27 am
by Guest
The problem is that you are trying to invoke the abstract methods of the IGUIWindow interface. To do what you want, you would have to inherit from CGUIWindow.

Posted: Thu Jan 12, 2006 5:50 pm
by miko93
Thank you all for your input.
The problem is that you are trying to invoke the abstract methods of the IGUIWindow interface. To do what you want, you would have to inherit from CGUIWindow.
Yeah, I think that is it. Seems I missed the concept a bit. :roll:
What I will do now is add the CGUIWindow class source to my project, then derive an own class from it. This should work, IMHO.

Again, thanks.

Posted: Fri Jan 13, 2006 3:36 am
by MikeR
What I will do now is add the CGUIWindow class source to my project
You don't need to move the source file. Just #include it in your own file and derive from it's functions.