Solved

Maximize MIDI Window

Posted on 1998-11-17
13
284 Views
Last Modified: 2013-11-20
I would like to Maximize a child window in a MIDI environment. The following code works but it is not the same as maximize. I have tried calling OnSize and SetWindowPos but it doesn't work. Please supply code sample

// make the view size itself to the size of the mainframe
      pMainFrame->MDITile();
0
Comment
Question by:gdawson
  • 6
  • 5
  • 2
13 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324863
Try this:

pMainFrame->SendMessage (WM_SYSCOMMAND, SC_MAXIMIZE, 0);

Does that work?
0
 

Author Comment

by:gdawson
ID: 1324864
I added the code in InitInstance. It didn't work
0
 
LVL 2

Accepted Solution

by:
wyy_cq earned 100 total points
ID: 1324865
you need to get the HWND (CWnd*) of the child window.
CMDIChildWnd* MDIGetActive( BOOL* pbMaximized = NULL ) const;
will help you .
when you get the active mdi child window CWnd*, you can call pChildWnd->ShowWindow(...);

CMDIFrameWnd::MDINext() will make the other child window active.
by this function you can browse all the child all.
 

0
 

Author Comment

by:gdawson
ID: 1324866
Where do I put the code? I want the window to to be maximized when it first appears. I tried putting the following code in OnInitialUpdate and OnUpdate but that didn't work because there isn't an active window.

CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame,
                                             AfxGetMainWnd());
      CMDIChildWnd* pMDIActive = pMainFrame->MDIGetActive();
      pMDIActive->ShowWindow(SW_SHOWMAXIMIZED );

0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324867
Oh, I see, you are asking something different from what I thought.  I thought you wanted to maximize the whole app.

Here is what you want to do.  Go to the CChildFrame::PreCreateWindow function and add

| WS_MAXIMIZE to the end of that statement.

This will make it maximize the CHILD window like you want.
0
 

Author Comment

by:gdawson
ID: 1324868
I am confused. Below is the PreCreateWindow function. Do you want me to modify the cs structure?

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs

      return CMDIChildWnd::PreCreateWindow(cs);
}

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324869
I can understand why you're confused, I would be too if I recieved the answer I gave you.  Yes, you should modify the cs structure, like so:

cs.style |= WS_MAXIMIZE;

That should do it.  That is, it will maximize the window inside your application by default.
0
 

Author Comment

by:gdawson
ID: 1324870
That didn't work. Stepping through MS code reveals that the precreate function get called at least 2 times. In the MS create function there is a line which looks like:

          mcs.style = cs.style & ~(WS_MAXIMIZE | WS_VISIBLE);

This turns off maximize. Then a second call is made to precreate, which agains turns on maximize. BUT because the MS_VISIBLE has been turned OFF the style is ignored. This is documented by the ms statement:

        // special handling of visibility (always created invisible)
      if (cs.style & WS_VISIBLE)
      {  ...

Therefore the folowing seems to work

         cs.style |= WS_MAXIMIZE | WS_VISIBLE ;

0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324871
Okay, I see, I am no pro at MFC.  But just out of curiousity, why did you accept "wyy_cq's" answer if it didn't work either?
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324872
Since there was no acceptable answer, you could have deleted the question and gotten your points back.
0
 

Author Comment

by:gdawson
ID: 1324873
Did I accept the wrong answer? I accepted only because it pointed me in the correct direction which allowed me to solve the problem. I was tempted to mark barely acceptable but I am an easy grader.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324874
Oh okay, as long as it helped you somehow.  From what I have seen in the past "wyy_cq" has a habit of answering a question when he doesn't know the answer for sure.
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1324875
thresher_shark,
you say i have a habit of answering the question.
i think i have not the habit what you said.

perhaps my answer is not correct, because i am from China.PRC i  can't get their point accuracily. and they did not declare their idea clearly.

i have developed with VC from 5 years.from 1.0 to now.
i encouter many problem just many persons encounter.
now let us browse your answer which is correct and which is have any thing to do with the question.

gdawson want to max the child window ,you teach him to max the frame window.what are you doing.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

15 Experts available now in Live!

Get 1:1 Help Now