CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    System Menu Buttons On Child Window

    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.


  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: System Menu Buttons On Child Window

    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
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: System Menu Buttons On Child Window

    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
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured