Solved

maximize the window during startup

Posted on 1999-01-04
6
390 Views
Last Modified: 2013-11-20
Hi,

  I am having trouble with maximizing window during startup. I have a SDI with a few splitter panes. I have overwritten CMainFrame::PreCreateWindow(CREATESTRUCT& cs) method like this:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs
      cs.style |= WS_MAXIMIZE ;
      return CFrameWnd::PreCreateWindow(cs);
}

But it DIDN'T work... May I know what's wrong with my code?

Thanks.

wyldsj
0
Comment
Question by:wyldsj
6 Comments
 
LVL 12

Expert Comment

by:migel
ID: 1327202
try call  ShowWindow(SW_SHOW); after caling CWinApp::InitInstance() in the your InitInstance

0
 

Expert Comment

by:koskia
ID: 1327203
cs.x = cs.y = 0;
cs.cx = ::GetSystemMetrics(SM_CXMAXIMIZED);
cs.cy = ::GetSystemMetrics(SM_CYMAXIMIZED);

this should do it, SM_CXMAXIMIZED and SM_CYMAXIMIZED,
are the client areas without desktop bar,
this should create a maximized window all over the desktop.
you can disable the maximize button and allow only to minimize, with changing the window style,
look at GetSystemMetrics for other coordinates, look at window styles for other styles.
0
 

Author Comment

by:wyldsj
ID: 1327204
thanks migel and koskia!
migel: In my CWinApp derived class, there is already a m_pMainWin->ShowWindow(SW_SHOW)  in the InitInstance().

koskia: After using your method, it worked! But can anyone explain why my previous code doesnot work? I am very puzzled on that... Also, koskia, please submit your comment again as answer and get the credit.

wyldsj
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Expert Comment

by:arunprakash
ID: 1327205
just replace the ShowWindow(nCmdShow)
as ShowWindow(SW_SHOWMAXIMIZE)
in the initinstance...that will do
thanx,
bye
arun

0
 

Accepted Solution

by:
matias103098 earned 30 total points
ID: 1327206
on your app Oninit Instance:

pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
0
 

Expert Comment

by:dagangwang
ID: 1327207
You  may  overwritten CMainFrame::ActivateFrame(int nCmdShow)  method like this:
void CMainFrame::ActivateFrame(int nCmdShow)
{
    nCmdShow = SW_SHOWMAXIMIZED;
    CFrameWnd::ActivateFrame(nCmdShow);
}

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question