Solved

A CView as a child of CMDIChildWnd

Posted on 2000-05-15
7
534 Views
Last Modified: 2013-11-20
I have a MDI child and CView, but in CMDIChild I have some toolbars as well. How can I do this: my CView shouldn't take all the client area (except toolbars) in CMDIChildWnd, and between CView and CMDIChild should be left 5 pixels in each side for example. Is it can be done by overloading some functions in CMDIChild or CView?
I tried this:
void CContainerView::OnSize(UINT nType, int cx, int cy)
{
      CView::OnSize(nType, cx-10, cy-10);
      CRect rct;
      GetParent()->GetClientRect(&rct);
      MoveWindow(5,5,rct.right-10,rct.bottom-10);
}
But it isn't take in account toolbars.
Important: toolbars are OLE server toolbars created by another application, and I don't know how many space they use.
0
Comment
Question by:double_axe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 3

Author Comment

by:double_axe
ID: 2813088
You may help, if just answer, how to change client rect of window dynamically, so that GetClientRect return this rect.
0
 
LVL 3

Author Comment

by:double_axe
ID: 2813110
You may help, if just answer, how to change client rect of window dynamically, so that GetClientRect return this rect.
0
 
LVL 12

Expert Comment

by:migel
ID: 2813285
Hi!
Try CMdiChildWnd::RecalcLayout(BOOL bNotify)

for example:
CMyMDIChildWnd::OnSize(...)
{
CMDIChildWnd::OnSize();
RecalcLayout(FALSE);
}
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.

 
LVL 3

Author Comment

by:double_axe
ID: 2815890
No, my example doesn't work 'cause GetParent()->GetClientRect(&rct); returns all the client rect, uncluding toolbars. I solved this problem by myself this way:

void CMyView::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
{
      CView::CalcWindowRect(lpClientRect, nAdjustType);

            lpClientRect->right-=5;
            lpClientRect->bottom-=5;
            lpClientRect->top+=5;
            lpClientRect->left+=5;
}

But I can give you some pts, 'cause I can't get them back;))
0
 
LVL 12

Accepted Solution

by:
migel earned 50 total points
ID: 2816051
hmm
In generaly MFC archeticture assume that child window must be resized by parent, not itself, so did you try my reccomendation (and remove CContainerView::OnSize(UINT nType, int cx, int cy) )?
0
 
LVL 3

Author Comment

by:double_axe
ID: 2816473
But that one workes pretty fine. And from within CMyMDIChildWnd::OnSize() it's possible too, but there will be more code (need to get size of CView, then substract some pixels from this size, and call MoveWindow to set new size, and only after this call RecalcLayout to arrange toolbars and CView).
0
 
LVL 3

Author Comment

by:double_axe
ID: 2840538
Hi migel. You were right:)). My method worked fine, when CView was a child of CMDIChild, but when I inserted it into CSplitterWnd, I didn't get any results. I tried some methods, but only one worked fine. Guess what?:))) I had to reimplement CSplitterWnd::RecalcLayout() as follows:
void CViewExSplitWnd::RecalcLayout()
{
      CSplitterWnd::RecalcLayout();
         CFrameWnd *pFrame=GetParentFrame();
         if(!pFrame)
               return;

         CView *pView=pFrame->GetActiveView();
         if(!pView)
               return;

         if(((CChildFrame *)pFrame)->m_bColoredFrame)
         {
               RECT rct;
               pView->GetWindowRect(&rct);
               pView->GetParent()->ScreenToClient(&rct);
               pView->MoveWindow(rct.left+ALERT_BORDER_SIZE,rct.top+ALERT_BORDER_SIZE,
                     rct.right-rct.left-2*ALERT_BORDER_SIZE,rct.bottom-rct.top-2*ALERT_BORDER_SIZE);
               pFrame->RedrawWindow();
         }
}

Generally you were right, parent must resize it's children. So, I'll accept your answer.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

621 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