closing, hiding or destroying a window , HELP!
Moderators: CEGUI MVP, CEGUI Team
closing, hiding or destroying a window , HELP!
Please help!
I am not only new to CEGUI, but also a clumsy programmer.
I am working on GUI for a simulation program, in which i need to make windows that pop up and close on command.
I create pop up window lay out in xml sheet, and call loadWindowLayout when a button is clicked to display these windows. That works just fine.
The problems come when i try to make these windows disappear (after finish using them):
I have tried to hide them:
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load");
mEditorGuiSheet->hide();
return true;
}
I have tried to destroy them:
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load");
CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
return true;
}
and these 2 methods both help my program to CRASH.
I've read some where that destroying a window that fires event may make my program crash. What should i do to avoid it? Why doesn't the hide method work?
i have looked around for a while and still can't figure out how to close any of the window i create. I appreciate everymuch your help. please leave let me know if you need more information about the problems.
Thanks
I am not only new to CEGUI, but also a clumsy programmer.
I am working on GUI for a simulation program, in which i need to make windows that pop up and close on command.
I create pop up window lay out in xml sheet, and call loadWindowLayout when a button is clicked to display these windows. That works just fine.
The problems come when i try to make these windows disappear (after finish using them):
I have tried to hide them:
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load");
mEditorGuiSheet->hide();
return true;
}
I have tried to destroy them:
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load");
CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
return true;
}
and these 2 methods both help my program to CRASH.
I've read some where that destroying a window that fires event may make my program crash. What should i do to avoid it? Why doesn't the hide method work?
i have looked around for a while and still can't figure out how to close any of the window i create. I appreciate everymuch your help. please leave let me know if you need more information about the problems.
Thanks
Re: closing, hiding or destroying a window , HELP!
is the crash happening after u hide the window or after u try to re-open it?
Re: closing, hiding or destroying a window , HELP!
the program would run fine without the code to hide or destroy the windows.
but if i put code to hide and destroy the windows in, the program crashes right after it starts. i dont even get to see my screen. a window just pops up saying "the application has requested the Runtime to termintate it in an unsual way. Please contact the application's support team for more information."
but if i put code to hide and destroy the windows in, the program crashes right after it starts. i dont even get to see my screen. a window just pops up saying "the application has requested the Runtime to termintate it in an unsual way. Please contact the application's support team for more information."
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: closing, hiding or destroying a window , HELP!
which CEGIU version?
How do you subscribe to your events?
Any logger errors?
How do you subscribe to your events?
Any logger errors?
Re: closing, hiding or destroying a window , HELP!
i think it is one versio older than the newest one, but i'm not sure. i dotn know how to figure it out. i just use this version since it comes with ogre3d v1.0.
here's the code i use to subcribe the events
if i take that last one subscribeEvent out, the program would run, but if it's in there the program would crash.
there's what's inside of the handleCancel
i have tried both hiding and destroying the window, neither of them work.
What is "logger error"? how do i find that out?
Appreciate the help very much
here's the code i use to subcribe the events
void setupEventHandlers(void)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/Quit")
->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleQuit, this));
wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo2/ControlWindow/ShowCodeBtn")
->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleShowCode, this));
wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/FileMenu")
->subscribeEvent(
CEGUI::Combobox::EventListSelectionAccepted,
CEGUI::Event::Subscriber(&GuiApplication::handleObjectSelection, this));
wmgr.getWindow((CEGUI::utf8*)"Load/MainWindow/LoadCancel")
->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleCancel, this));
}
if i take that last one subscribeEvent out, the program would run, but if it's in there the program would crash.
there's what's inside of the handleCancel
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load/MainWindow");
mEditorGuiSheet->hide();
return true;
}
or
bool handleCancel(const CEGUI::EventArgs& e)
{
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Load/MainWindow");
CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
return true;
i have tried both hiding and destroying the window, neither of them work.
What is "logger error"? how do i find that out?
Appreciate the help very much
Re: closing, hiding or destroying a window , HELP!
It seems that there is inconsistency between the declaration of you window in the layout file and the event subscribe declaration.
Please verify the name of the window.
is it "Load/MainWindow/LoadCancel" or "Load/MainWindow" or anything else ?
You have to match the window name!
The "Error Log" is that file called Cegui.log in the execution directory.
You can find the CeGUI version number in. And other error message.
Each time you have an error and want some help, please copy the exact error message.
Gaal
Please verify the name of the window.
is it "Load/MainWindow/LoadCancel" or "Load/MainWindow" or anything else ?
You have to match the window name!
The "Error Log" is that file called Cegui.log in the execution directory.
You can find the CeGUI version number in. And other error message.
Each time you have an error and want some help, please copy the exact error message.
Gaal
Re: closing, hiding or destroying a window , HELP!
Gaal wrote:
It seems that there is inconsistency between the declaration of you window in the layout file and the event subscribe declaration.
Please verify the name of the window.
is it "Load/MainWindow/LoadCancel" or "Load/MainWindow" or anything else ?
You have to match the window name!
the windows' names dont match because they're for different window componentz. Load/MainWindow/LoadCancel is a button that i'd like to click on to fire closing event for Load/MainWindow, which is a window. it just happen that the LoadCancel button is on the MainWindow.
it's sort of like when you open a window to do something, then decide not todo it, so you click cancel, to close that window away.
The "Error Log" is that file called Cegui.log in the execution directory.
You can find the CeGUI version number in. And other error message.
Each time you have an error and want some help, please copy the exact error message.
yeah the log file helps me to understand some stuff better. it doesn't work yet, i'm learning about event subscribing still.
i'll post again, when i get to the point to ask questions again. thanks for your help
Re: closing, hiding or destroying a window , HELP!
things work now, thank you for your help.
however, i do have another problem related to closing a window. i was instructed to do this in order to subscribe an event fired by the closeButton on a frame window:
but when i compile this, i have these errors:
i have checked 2 million times to make sure FrameWindow was not misspelled. how else can it be undefined?
however, i do have another problem related to closing a window. i was instructed to do this in order to subscribe an event fired by the closeButton on a frame window:
void setupCloseButtonHandlers(CEGUI::Window* window)
{
window->subscribeEvent(
CEGUI::FrameWindow::EventCloseClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleCloseButton, this));
}
but when i compile this, i have these errors:
error C2027: use of undefined type 'FrameWindow'
c:\ogresdk\include\cegui\ceguiforwardrefs.h(80) : see declaration of 'FrameWindow'
error C2065: 'EventCloseClicked' : undeclared identifier
i have checked 2 million times to make sure FrameWindow was not misspelled. how else can it be undefined?
- scriptkid
- Home away from home

- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Re: closing, hiding or destroying a window , HELP!
i have checked 2 million times to make sure FrameWindow was not misspelled. how else can it be undefined?
A type is never just "FrameWindow" or "Button". There's always a looknfeel prefix, so it becomes "WindowsLook/FrameWindow" for example.
[EDIT] i see it a compile error now; did you use the CEGUI namespace or prefix FrameWindow with it?
[/EDIT]
As a hint for your original post: Always test returned pointers (in this case windows) for not being NULL, before calling methods on it!
Good luck
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: closing, hiding or destroying a window , HELP!
include "CEGUI.h" or at least "elements/CEGUIFrameWindow.h"
Re: closing, hiding or destroying a window , HELP!
Thank you, i did include the header file in and it works now. But geesh, the problems dont come individually, they come in herds :D
therefore, i have other problems that i need help with. i scoured the site and couldn't find anything that would answer this.
so i ran my Gui app, i opened a window within it. then, i closed it. AND I WANT TO OPEN IT BACK UP AGAIN, but the program CRASHESwhen i try to click o button to open in back up.
here's how the code look:
i dont quite understand how these windows and sheets get attached and detached.
in short, the whole problem is i need to be able to open a window within the program, use it, be able to close it, and reopen it if i need to. i would be very thankful, if you guys an educate me a bit about these things, or at least show me where to go in the site that i can learn more about this. i did most of this, just looking demo code. i understand some, but not all that i did there.
thank you
therefore, i have other problems that i need help with. i scoured the site and couldn't find anything that would answer this.
so i ran my Gui app, i opened a window within it. then, i closed it. AND I WANT TO OPEN IT BACK UP AGAIN, but the program CRASHESwhen i try to click o button to open in back up.
here's how the code look:
void setupEventHandlers(void)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.getWindow((CEGUI::utf8*)"OgreGuiDemo/FileMenu")
->subscribeEvent(
CEGUI::Combobox::EventListSelectionAccepted,
CEGUI::Event::Subscriber(&GuiApplication::handleObjectSelection, this));
}
bool handleObjectSelection(const CEGUI::EventArgs& e)
{
static unsigned int load = 0;
static unsigned int save = 1;
String guiObjectName;
CEGUI::Window* window = 0;
// Set a position to place this object.
Real posX = 0.5;
Real posY = 0.5 ;
const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();
CEGUI::Window* editorWindow = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"OgreGuiDemo2");
switch(item->getID())
{
case 0:
if(mEditorGuiSheet)
mEditorGuiSheet->destroy();
mEditorGuiSheet = CEGUI::WindowManager::getSingleton().loadWindowLayout(
(CEGUI::utf8*)"LoadWin.layout");
setupLoadWindowHandlers();
break;
};
editorWindow->addChildWindow(mEditorGuiSheet);
return true;
}
void setupLoadWindowHandlers(void)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
mCancelBtn =
wmgr.getWindow((CEGUI::utf8*)"Load/MainWindow/LoadCancel");
mCancelBtn->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&GuiApplication::handleCancel, this));
}
bool handleCloseButton(const CEGUI::EventArgs& e)
{
static_cast<const CEGUI::WindowEventArgs&>(e).window->hide();
return true;
}
i dont quite understand how these windows and sheets get attached and detached.
in short, the whole problem is i need to be able to open a window within the program, use it, be able to close it, and reopen it if i need to. i would be very thankful, if you guys an educate me a bit about these things, or at least show me where to go in the site that i can learn more about this. i did most of this, just looking demo code. i understand some, but not all that i did there.
thank you
- martignasse
- Just can't stay away

- Posts: 227
- Joined: Thu Apr 14, 2005 08:10
- Location: Lyon, FRANCE
Re: closing, hiding or destroying a window , HELP!
from the code you posted, i can't say what is wrong.
But basicly, if you have a window you want to use many time in the appli, you don't have to destroy it and reload it every time, just hide() and show() it.
But basicly, if you have a window you want to use many time in the appli, you don't have to destroy it and reload it every time, just hide() and show() it.
Re: closing, hiding or destroying a window , HELP!
i have tried hiding. it causes the same problem.
this is how is hide a window. i copied it from somewhere, so i dont really understand what it's doing there, besides that '->hide()'. How does it know what to hide? What do all that in front of "->hide()" mean? ... since i dont understand completely, i'm not sure how to show a window correct after hiding it.
here's how that code for hiding looks:
this is how is hide a window. i copied it from somewhere, so i dont really understand what it's doing there, besides that '->hide()'. How does it know what to hide? What do all that in front of "->hide()" mean? ... since i dont understand completely, i'm not sure how to show a window correct after hiding it.
here's how that code for hiding looks:
bool handleCloseButton(const CEGUI::EventArgs& e)
{
static_cast<const CEGUI::WindowEventArgs&>(e).window->hide();
return true;
}
- martignasse
- Just can't stay away

- Posts: 227
- Joined: Thu Apr 14, 2005 08:10
- Location: Lyon, FRANCE
Re: closing, hiding or destroying a window , HELP!
it wasn't to resolve the error but more in an "educate" wayi have tried hiding. it causes the same problem.
problem with lot of copy/past from lot of different sources is that you finish with lot of bug.
What do all that in front of "->hide()" mean?
if you don't understand it....don't copy/past it
"static_cast<const CEGUI::WindowEventArgs&>(e).window" extract a pointer to the window who fire the event.
i suggest you to make some minimal projects with only CEGUI (not with orge, based on the SampleApp) and only the fonctionnality you want to test/anderstand.
Like that, you only have the code relevant to the fonctionnality, it's easy to understand and to debug.
and look in the cegui.log (located in the exe folder), it can help(sometime) to locate the error.
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 16 guests

