Solved

Adjusting frame size in an SDI

Posted on 1997-12-31
8
334 Views
Last Modified: 2013-11-20
How can I best adjust an SDI frame size such that either:

   1. Only toolbars and dialog bars are displayed,
      even if the user decides to adjust the size
      of the frame.
   2. Only a CFormView is displayed (not my preferred
      choice due to the quality of display, particularly
      in terms of 3D and extra space between the
      dialog and the frame.

I don't want to use a dialog based application. Possibly one route is to get rid of the document class, since as I indicated, I really want to get rid of the document view.

Thanks for your input.
RJV
0
Comment
Question by:RJV
[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
  • 4
  • 4
8 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1313275
You must handle WM_GETMINMAXINFO message in your frame class and set maximum and minimum sizes.
0
 

Author Comment

by:RJV
ID: 1313276
Please be a bit more specific. Namely, how to change the size of the frame to display only the toolbars and dialog bar or CFormView bar?

I ran some tests here and found that WM_GETMINMAXINFO gets called before CMainFrame::OnCreate(). Thus the frame hasn't even been created at that point, nor have any toolbars or the dialog bar. Thus, I can't have it resize at that point, for example. Moreover, the size information is a bit confusing.

RJV

0
 
LVL 7

Expert Comment

by:galkin
ID: 1313277
Ok, WM_GETMINMAXINFO is sent to parent frame window when ANY operation touching upon changing size of the window is about to be processed. For instance when you minimize/maximize/restore or resize window. This allows you to prevent changing of window size. So you want to show only toolbar and dialog bar, i.e. you want client area of your frame(view) to be zero sized. So
you should do the following.

void CMainFrame::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
{
CFrameWnd::OnGetMinMaxInfo( lpMMI );

CRect rc(0,0,0,0);
//calculate window rectangle based on zero sized client area
CalcWindowRect(&rc);
// restict window both track and max size
ptMaxSize.x = ptMaxTrackSize.x = rc.Width();
ptMaxSize.y = ptMaxTrackSize.y = rc.Height();
}
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RJV
ID: 1313278
Galkin, you've gotta try that one yourself. I guarantee the outcome to be a good laugh! The resizing so effective it'll be somewhat of a challenge to find the application.

This is most probably thanks to the moment the message is activated.

RJV

0
 
LVL 7

Expert Comment

by:galkin
ID: 1313279
I am sorry I missed two important things.
First CalcWindowRect doen's add menu to adjusted recangle, and second you should check whether your bars window exist.

This is improved code for window which has only one tool bar but it can be easily extended for several control bars

1.Add WM_GETMINMAXINFO handler to your parent frame and implement the following code(m_wndToolBar is member variable of type CToolBar, generated by AppWizard)
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// TODO: Add your message handler code here and/or call default

      if(m_wndToolBar.GetSafeHwnd())
      {
      CRect rc;
      m_wndToolBar.GetWindowRect(&rc);
      ScreenToClient(&rc);

      ::AdjustWindowRectEx(&rc, GetStyle(), TRUE, NULL);
 
      // restict window both track and max size
      lpMMI->ptMaxSize.x = lpMMI->ptMinTrackSize.x =
lpMMI->ptMaxTrackSize.x = rc.Width();
      lpMMI->ptMaxSize.y = lpMMI->ptMinTrackSize.y =
lpMMI->ptMaxTrackSize.y = rc.Height();
      }
      
      CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

2.After toolbar window is created in CMainFrame::OnCreate handler call ShowWindow(SW_SHOWMAXIMIZED);
0
 

Author Comment

by:RJV
ID: 1313280
Super! Since Murphy is having fun with coding (coding is a favorite of his anyway), there are two areas to be repaired with this:

  1. A lot of screen flicker upon starting up. It is
     evident that the screen gets maximized and then
     resized.

  2. If you've tried this you'll have to fix it to
     include the status bar, which I did by adding
     in its CRect.height. The problem is if you try to
     increase the size of the screen you wind up with
     a blank line between the dialog bar and the status
     bar.

BTW, don't forget to tell Murphy to go packing first!

RJV

0
 
LVL 7

Expert Comment

by:galkin
ID: 1313281
I just showed you the idea. Of cause to implement this as it must be implemented you should not rely upon AdjustWindowRectEx but to calculate the frame window recatngle based on zero client rectangle and all control bars you have. Then you should not call ShowWindow which of cause causes flickeing since window is already displayed. You should create your parent frame invisible and show it only when all your control bars are created and set it window position using SetWindowPos after calculating the size using the same method used in calculating window rectangle in OnGetMinMaxInfo.
0
 

Author Comment

by:RJV
ID: 1313282
I was wondering if the solution you'd suggest would go through setting the frame to invisible. I'll see why moving things later cause the problem too.

RJV

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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