Thursday, July 23, 2009

How to disable maximizing the dialog from Task manager?

You can do it by handling – WM_GETMINMAXINFO message. Before resizing, this message is fired to the dialog to get the minimum and maximum window dimensions. Since, we don’t need to change our dimensions, we have to set the max dimensions as current window dimension. Have a look at the code snippet.

// Message map
BEGIN_MESSAGE_MAP(CRabbitDlg, CDialog)
...
ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()

void CRabbitDlg::OnGetMinMaxInfo( MINMAXINFO FAR* pMinMaxInfo )
{
// Window rect.
RECT rect = { 0 };
GetWindowRect( &rect );
CRect WindowRect( &rect );

// Set the maximum size. Used while maximizing.
pMinMaxInfo->ptMaxSize.x = WindowRect.Width();
pMinMaxInfo->ptMaxSize.y = WindowRect.Height();

// Set the x,y position after maximized.
pMinMaxInfo->ptMaxPosition.x = rect.left;
pMinMaxInfo->ptMaxPosition.y = rect.top;
}



0 comments:

  © Free Blogger Templates Blogger Theme II by Ourblogtemplates.com 2008

Back to TOP