Click to See Complete Forum and Search --> : System Menu Buttons On Child Window


Todd88
April 29th, 1999, 04:39 PM
I am currently trying to find a way to disable the Minimize, Restore, and Close buttons on a Child Window of an MDI Project. When the child window is not maximized I have had success disabling the Minimize button by calling GetWindowLong and checking the WS_MAXIMIZE or WS_MINIMIZE bits. However, when the child window is maximized in the parent windows client space. These three button appear on the applications main menu bar. I have not been able to disable them in this situation. I have tried using GetWindowLong and SetWindowLong, as well as using GetSystemMenu to get a handle to the ChildFrames system menu, and then trying to disable these items using that handle. So far I have had no luck. Any suggestion would be greatly appreciated.

JohnCz
May 21st, 1999, 12:05 PM
You are doing it hard way and using wrong flags.

Try this:
In your PreCreateWindow implementation for a child frame insert following lines after call to the base class, before return:

cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE,
AfxGetApp()->LoadStandardCursor(IDC_ARROW),
(HBRUSH)(COLOR_BACKGROUND+1),
AfxGetApp()->LoadIcon(IDR_YOUR_ICON_ID)); //icon id the same as for other resoueces you registered template with.

// cs.style &= ~WS_MAXIMIZEBOX;
cs.style &= ~WS_MINIMIZEBOX;




John Cz

JohnCz
May 21st, 1999, 12:11 PM
I should have been be more specific as to the changes:

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{

if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE,
AfxGetApp()->LoadStandardCursor(IDC_ARROW),
(HBRUSH)(COLOR_BACKGROUND+1),
AfxGetApp()->LoadIcon(IDR_MDINORTYPE));

// cs.style &= ~WS_MAXIMIZEBOX;
cs.style &= ~WS_MINIMIZEBOX;

return TRUE;
}




John Cz