How to catch window resize event

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
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

How to catch window resize event

Post by greenya »

Hello.

When we create device in window mode, and do device.SetWindowResize(true), we get resize-able window. But how to catch the event when the window actually resized, so we can react properly if needed?

The only way i currently found is:

Code: Select all

// somewhere in device' event handling routine:

			if (evnt.Type == EventType.Log)
			{
				// we check for log message like "Resizing window (640 480)"
				string b = "Resizing window (";
				string s = evnt.Log.Text;
				if (s.StartsWith(b))
				{
					s = s.Substring(b.Length, s.Length - b.Length - 1);
					string[] v = s.Split(' ');
					int w = int.Parse(v[0]);
					int h = int.Parse(v[1]);
					// HERE WE KNOW THAT WINDOW HAS BEEN RESIZED TO w x h
				}
			}
or another way: check device.VideoDriver.ScreenSize in main loop each time after device.Run().

I don't know which method is better, they both looks to me quite ugly :?

Please, let me know is there any other way to catch the moment when user has changed window size.
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Post by Iyad »

If I was you, i would simply check out if the window size has been changed each loop. I looked quickly at the irrlicht api and I didnt find anything related. Yes it may look ugly, but its a really simple solution.
Last edited by Iyad on Mon Sep 20, 2010 2:21 pm, edited 1 time in total.
#include <Iyad.h>
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

I agree with Iyad, it sounds to be the best solution. If you're on Windows, you can always check for the Windows event.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This is why we want to create the system events, which would cover issues like this. It's indeed currrently not possible besides the mentioned two ways.
Post Reply