How to hide/show buttons on a GUIWindow using loadGUI.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ericaus
Posts: 14
Joined: Sat Sep 19, 2009 10:53 am
Location: Australia

How to hide/show buttons on a GUIWindow using loadGUI.

Post by ericaus »

Hello, just wondering how do I hide or show the minimize, maximize and close buttons on a GUI window that is inside an xml that was created with GUIEditor?

On a test project I've tried doing something like...

Code: Select all

........

IGUIEnvironment* env = device->getGUIEnvironment();

env->loadGUI("LoginGUI.xml");

IGUIWindow* window = env->getRootGUIElement()->getElementFromId(1, false);
window->getCloseButton()->setVisible(false);

........
but with that I end up getting an error when I try to build solution.

Code: Select all

 error C2440: 'initializing' : cannot convert from 'irr::gui::IGUIElement *' to 'irr::gui::IGUIWindow *'
the window would load if i leave out the IGUIWindow* window part but then I cant get the getCloseButton function.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you know the pointer returned by getElementFromId() is derived from IGUIWindow, you can just use a cast.

Code: Select all

IGUIWindow* window = static_cast<IGUIWindow*>(env->getRootGUIElement()->getElementFromId(1, false));
Travis
ericaus
Posts: 14
Joined: Sat Sep 19, 2009 10:53 am
Location: Australia

Post by ericaus »

Awesome it works. Thank you for the help. :D
Post Reply