Solved

Maximize MIDI Window

Posted on 1998-11-17
13
286 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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
 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 184
Detect CR LF to each line 12 160
conditional code and condition difference 9 82
haveThree challenge 22 118
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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

770 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