From 0615013a733e03f2d51622221a6a566cd9e89ea4 Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sun, 6 Jan 2008 13:50:09 +0000 Subject: [PATCH] add minimum window size git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@265 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/MainWnd.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index ce126b6b..f266077f 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -775,12 +775,34 @@ void MainWnd::OnMove(int x, int y) } void MainWnd::OnSizing(UINT fwSide, LPRECT pRect) -{ +{ // the OnSizing event only occurs in windowed mode CWnd::OnSizing(fwSide, pRect); + // pause sound to prevent low sound buffers if( emulating ) { soundPause(); } + + // maintain minimal window size + RECT size = { 0, 0, theApp.sizeX, theApp.sizeY }; + AdjustWindowRectEx( + &size, + WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW, + FALSE, + 0 ); + MENUBARINFO mbi; + mbi.cbSize = sizeof(MENUBARINFO); + this->GetMenuBarInfo( OBJID_MENU, 0, &mbi ); + const LONG menuHeight = mbi.rcBar.bottom - mbi.rcBar.top + 1; + // +1 because of that white line, wherever it comes from + const LONG width = size.right - size.left; + const LONG height = size.bottom - size.top + menuHeight; + if( ( pRect->right - pRect->left ) < width ) { + pRect->right = pRect->left + width; + } + if( ( pRect->bottom - pRect->top ) < height ) { + pRect->bottom = pRect->top + height; + } } void MainWnd::OnSize(UINT nType, int cx, int cy)