Solved

Adjusting frame size in an SDI

Posted on 1997-12-31
8
295 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
  • 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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…

746 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

12 Experts available now in Live!

Get 1:1 Help Now