Detecting the closing of a window

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Kosomot
Posts: 5
Joined: Sun Apr 17, 2005 12:26 pm
Location: Poland
Contact:

Detecting the closing of a window

Post by Kosomot »

Hi all,

Well, I have a question: is there a way to detect when a user closes a GUI window (something like the WM_CLOSE message in WINAPI)?
This doesn't seem to work:

Code: Select all

IGUIWindow *wnd=gui->addWindow(...);
IGUIButton *btn=wnd->getCloseButton();
btn->setID(10);

...

//in the event reciever:
	switch(event.EventType)
	{
		case EET_GUI_EVENT:
			switch(event.GUIEvent.EventType)
			{
				case EGET_BUTTON_CLICKED:
				        switch(event.GUIEvent.Caller->getID())
				        {
				        case 10:
				              //do something
				              return true;
				        }
					break;
			}
			break;
	}
	return false;
Any ideas?[/code]
hybrid

Post by hybrid »

The close button has a default handler, so you won't get the event. There is a patch availabel to remove default handling. Search for it in the forums.
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

This is an idea that just came into my mind. It's a way without modifying the engine, although it has a hackish touch:

1. Get and hide the original close button (getCloseButton)
2. Create a new button with same configuration as the original one (text, font, position) and place it as child into the window.

The events of that "button clone" won't get catched by the window.
It is like it is. And because it is like it is, things are like they are.
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

yeah, i've done that before. Its kinda ugly but it works
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Kosomot
Posts: 5
Joined: Sun Apr 17, 2005 12:26 pm
Location: Poland
Contact:

Post by Kosomot »

jox wrote:This is an idea that just came into my mind. It's a way without modifying the engine, although it has a hackish touch:

1. Get and hide the original close button (getCloseButton)
2. Create a new button with same configuration as the original one (text, font, position) and place it as child into the window.

The events of that "button clone" won't get catched by the window.
Thanks alot. :)
Post Reply