Click here to Skip to main content
11,802,222 members (53,899 online)
Click here to Skip to main content

Tagged as

How to load a view in maximized mode by default in MFC

, 13 Jun 2011 CPOL 9.2K 2
Rate this:
Please Sign up or sign in to vote.
Addresses the issue of opening a view in maximized mode the proper way in MFC.
Override CFrameWnd::ActivateFrame and pass SW_SHOWMAXIMIZED to the base class function.

class CChildFrame : public CMDIChildWnd
// ...
   // Overrides
   // ClassWizard generated virtual function overrides
   virtual void ActivateFrame(int nCmdShow = -1);
// ...

void CChildFrame::ActivateFrame(int nCmdShow) 
// TODO: Add your specialized code here and/or call the base class
    if (nCmdShow == -1)
        // Show the window in maximized mode 
        // if and only if it is the very first frame
        // Otherwise, do default for user conveniences
        // The user may prefer to keep a previously created view and 
        // frame in restored (not maximized) mode
        // So, it is advisable to keep the newly created view and frame 
        // in the same state as already created views
        if(GetNextWindow() == NULL && GetNextWindow(GW_HWNDPREV) == NULL)
            nCmdShow = SW_SHOWMAXIMIZED;

Thanks to[^].


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
Your Lord does not like people who waste by extravagance, and only the righteous C s, and does so in increments, and they are of those people who are mindful of what memory and time has in offer and they waste none of it.

You may also be interested in...

Comments and Discussions

QuestionThanks a lot Pin
sameera wijerathne23-Mar-12 0:05
membersameera wijerathne23-Mar-12 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151002.1 | Last Updated 13 Jun 2011
Article Copyright 2011 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid