A Journey 2 Eternity

Handle minimize maximize event

Posted on: December 1, 2008

Handle the WM_SYSCOMMAND message. The buttons and menu items on the title bar
are all “system commands” and will generate this message. You’ll need to mask
the ID with 0xFFF0 to remove the lowest 4 bits before determining which command
was sent.

Example code:

void CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )
{
	UINT nCmd = (nID & 0xFFF0) ;
	switch ( nCmd ) {
		case SC_SIZE:
			// Do something here when user chooses Size command
		break ;

		case SC_MOVE:
			// Do something here when user chooses Move command
		break ;

		case SC_CLOSE:
			// Do something here when user chooses Close or presses X button
		break ;

		case SC_MAXIMIZE:
			// Do something here when user chooses Maximize or presses Maximize button
		break ;

		case SC_MINIMIZE:
			// Do something here when user chooses Minimize or presses Minimize button
		break ;

		case SC_RESTORE:
			// Do something here when user chooses Restore or presses Restore button
		break ;

		default:
			;
	}

	CFrameWnd::OnSysCommand( nID, lParam ) ;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

December 2008
M T W T F S S
« Sep   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Blog Stats

  • 27,491 hits
%d bloggers like this: