Thread: Enable/Disable Frame Buttons :: MFC

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    Enable/Disable Frame Buttons :: MFC

    Hi.

    In both windows and dialog boxes, there are buttons on the upper right corner of the frame to minimize, maximize, and/or close window. Is it possible to enable or disable one or more of those buttons? For example, I would like to disable the maximize option during a certain time and then reenable it.

    Thanks,
    Kuphryn

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Sure......but you need to alter the params sent to CreateWindow....

    Or as you do MFC, have a look at the PreCreateWindow() handler....

    You should be able to get away with something like this

    Code:
    BOOL CMyWindow::PreCreateWindow(CREATESTRUCT &cs){
    
    if(!CFrameWnd::PreCreateWindow(cs))
    return FALSE;
    
    cs.style &= ~WS_MAXIMIZEBOX;
    
    cs.lpszClass = AfxRegisterWndClass(NULL);
    return TRUE;
    
    }
    Havent tested it though...look it up

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Thanks.

    I was thinking more of a way to enable/disable them in real-time.

    Kuphryn

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Hmm....I dont see why you would want to do this.......but hell its your proggy...

    I'm not sure there's an easy way to do it.......Maybe you could create a window without the max & min buttons and then create & animate them yourself......you're window is sent WM_NCLBUTTONDOWN , WM_NCLBUTTONUP and WM_NCPAINT messages to allow you to work in the title bar....it would be a b*tch of a job though

    Sorry I cant offer a better idea...there may be one, but I'm not sure...maybe you could find a handle to these buttons and control them from there.......spy++ doesnt seem to want to know them so

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Thanks.

    Sonu Kapoor posted the solution to catch WM_CLOSE message and add whatever code you wanted before the window and/or dialog box close.

    Kuphryn

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Just a guess

    Try enable or disable SC_MINIMIZE, SC_MAXIMIZE commands in the system menu of the window. These are linked to the buttons I think.

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Hey,

    Nishant S of CodeProjects posted a key solution that opens up whole new horizon of menu controls.

    http://www.codeproject.com/script/c...7289#xx217289xx

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog in Frame: Buttons disabled
    By prongs_386 in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2007, 01:37 AM
  2. Animation not working....
    By aquinn in forum C Programming
    Replies: 7
    Last Post: 02-19-2005, 05:37 AM
  3. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  4. Optional Push-Buttons Around Frame :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 05-09-2002, 03:18 PM
  5. Enable/Disable A Window in SplitView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 05-06-2002, 10:26 PM