[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Maximize MIDI Window

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
gdawson
Asked:
gdawson
  • 6
  • 5
  • 2
1 Solution
 
thresher_sharkCommented:
Try this:

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

Does that work?
0
 
gdawsonAuthor Commented:
I added the code in InitInstance. It didn't work
0
 
wyy_cqCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
gdawsonAuthor Commented:
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
 
thresher_sharkCommented:
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
 
gdawsonAuthor Commented:
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
 
thresher_sharkCommented:
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
 
gdawsonAuthor Commented:
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
 
thresher_sharkCommented:
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
 
thresher_sharkCommented:
Since there was no acceptable answer, you could have deleted the question and gotten your points back.
0
 
gdawsonAuthor Commented:
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
 
thresher_sharkCommented:
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
 
wyy_cqCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now