MyGUI/Ogre - resizing window in non-fullscreen app

simed

01-11-2011 12:07:25

My app runs non-fullscreen and therefore lets user resize the main window (Win32 only for now). When they resize window, I don't want to scale MyGUI - I want to keep 1 pixel in renderwindow as one pixel in MyGUI. i.e. if I maximize my app, the MyGUI 'desktop' should have more space and show things the same size, not make everything look bigger... just like resizing a standard Win32 app.

I have a working solution but I am not sure it should be this complex - this method is called when I receive WM_SIZE message:
windowResized(int w, int h)
{
//standard functionality to tell Ogre to resize render window
m_renderWindow.windowMovedOrResized();

//special functionality to change MyGUI 'desktop' area
//rather than just scale to fit renderwindow
typedef Ogre::WindowEventUtilities::WindowEventListeners::iterator witerator;
std::pair<witerator,witerator> range =
Ogre::WindowEventUtilities::_msListeners.equal_range(&m_renderWindow);

for(witerator it = range.first; it!=range.second; ++it)
{
it->second->windowResized(it->first);
}
}
It makes me nervous having to hack around Ogre internals - this works but I don't understand why I manually have to trigger listeners. Can anyone offer insight?