Solved

maximize the window during startup

Posted on 1999-01-04
6
386 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
Comment Utility
try call  ShowWindow(SW_SHOW); after caling CWinApp::InitInstance() in the your InitInstance

0
 

Expert Comment

by:koskia
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Expert Comment

by:arunprakash
Comment Utility
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
Comment Utility
on your app Oninit Instance:

pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
0
 

Expert Comment

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

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Importing  SSL Certificate into Firefox using GPO 28 192
Unix / Linux grid computing 5 125
Hibernate methods 2 58
twoTwo  challenge 35 85
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now