Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make init view maximized

63 views
Skip to first unread message

Jimmy Han

unread,
Jan 28, 1998, 3:00:00 AM1/28/98
to

In a MDI app, how to make the initial view maximized? Take the sample
scribble, I tried adding

cs.style |= WS_MAXIMIZE;

in CChildFrame:PreCreateWindow(), but this does not work.

Thanks in advance for helps.
--
Jimmy Han

Ron Wolbeck

unread,
Jan 28, 1998, 3:00:00 AM1/28/98
to

Jimmy Han wrote in message <34CFB8...@cisco.com>...


>In a MDI app, how to make the initial view maximized? Take the sample
>scribble, I tried adding
>
>cs.style |= WS_MAXIMIZE;
>
>in CChildFrame:PreCreateWindow(), but this does not work.

How can I create an application that is initially maximized?
For new applications, this can be done with AppWizard during Step 4. During
Step 4, choose Advanced..., and then select the Main Frame tab. Check the
Maximized option.
For an MDI application, in the CWinApp::InitInstance() function, set
CWinApp::m_nCmdShow to SW_SHOWMAXIMIZED before calling
pMainFrame->ShowWindow(m_nCmdShow). In an application generated by
AppWizard, the code is as follows:
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_nCmdShow = SW_SHOWMAXIMIZED; // ADD THIS LINE!
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
m_pMainWnd = pMainFrame;
In an SDI application, in the CWinApp::InitInstance() function, set
CWinApp::m_nCmdShow to SW_SHOWMAXIMIZED before calling OnFileNew().For
example, in an application generated by AppWizard, the code is as follows:
m_nCmdShow = SW_SHOWMAXIMIZED;
//
// create a new (empty) document
OnFileNew();
MSVC Knowledge Base, 6/4/95


Jimmy Han

unread,
Jan 28, 1998, 3:00:00 AM1/28/98
to

I want to know how to make the document view window, that is the child
window of the main frame, to appear initially maximized, not the
application. The reply did not answer my question.

-
Jimmy Han

Pete Cozens

unread,
Jan 29, 1998, 3:00:00 AM1/29/98
to

Try something like this...

CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();

// Other initialisation
...

// Check to see if this is the first (only) view

if (IsOnlyView())
{
// Maximize the CMDIChildWnd object containing the view,
// rather than the view itself

GetParent()->ShowWindow(SW_SHOWMAXIMIZED);
}
}

BOOL CMyView::IsOnlyView()
{
int iOtherViews = 0;
CMyDoc* pDoc = GetDocument();
CDocTemplate* pTemplate = pDoc->GetDocTemplate();
POSITION pos = pTemplate->GetFirstDocPosition();

while(pos)
{
CDocument* pDoc = pTemp->GetNextDoc(posDoc);
POSITION posView = pDoc->GetFirstViewPosition();
while (posView)
{
CView* pView = pDoc->GetNextView(posView);
if (pView != this)
{
iOtherViews++;
}
}
}

return (iOtherViews == 0);
}

--

Pete
p.co...@XXXacecad.demon.co.uk
(remove the XXX to e-mail)

Jimmy Han <jh...@cisco.com> wrote in article <34CFB8...@cisco.com>...


> In a MDI app, how to make the initial view maximized? Take the sample
> scribble, I tried adding
>
> cs.style |= WS_MAXIMIZE;
>
> in CChildFrame:PreCreateWindow(), but this does not work.
>

0 new messages