How do you detect a window closing

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
MindGames
Posts: 32
Joined: Sat Jul 16, 2005 2:02 am

How do you detect a window closing

Post by MindGames »

Is there a way to monitor a window so that you get an event when it closes (or failing that, an event when the close button is clicked)

Is there are way of making the titlebar or even just the close button not show?
Irme
Posts: 55
Joined: Sat Jul 16, 2005 8:24 am

Post by Irme »

when the .close() function of a form is issued, the closing event is fired, one of the arguments passed to the closing event is cancel. bascily all you have to do is

Code: Select all

  e.Cancel = True 
and it will stop the form from closing.
MindGames
Posts: 32
Joined: Sat Jul 16, 2005 2:02 am

Post by MindGames »

Sorry I wasn't very clear. I meant a Irrlicht window (IGUIWindow).

You only get back an IGUIElement back from the AddWindow function so you do not have access to the CloseButton. I have tried to do a GetElementFromPoint and remove the control but the GetElementFromPoint function does not 'see' the button control. I can't quite see why this is the case as it appears to use the standard mechanism for adding it. I haven't looked at the .Net side of things to see how all this works though.

I am almost at the point of just adding another button on top of the close button and catching its key press event.
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Post by Sergio Cossa »

I made an application in VS 2003 to take off the doubts that it was a problem of C# Express Beta 2.
The button doesn't work to close the window GUI, neither the BUTTON_CLICKED event works...

The event click that recognizes is that of EventType.MouseInput

Similar to what I comment in another thread, the GUI events ELEMENT_HOVERED and ELEMENT_LEFT work correctly.

EDIT

Extracted of TODO.txt for Irrlicht.NET:
- GUI Environment

and in changes.txt:
- Irrlicht.NET includes now all basic GUI Elements and can capture GUI events. There are
still some features missing, but it is already enough to do simple things like showing
message boxes, displaying images, getting input strings, etc.
Sergio Cossa
Argentina
MindGames
Posts: 32
Joined: Sat Jul 16, 2005 2:02 am

Post by MindGames »

Ah now there's an idea, just capture the mouse event when it is above the button and return true. That will work.

I suppose I could also just wait until Niko gets a bit more done on the GUI - it's not that critical just yet. Hopefully he will implement something a bit like Win32's Styles concept whereby you can control what the window is like nice and simply.
Locked