Monday, December 1, 2008

Handle minimize maximize event

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 ) ;

}

No comments: