Solved

Adjusting frame size in an SDI

Posted on 1997-12-31
8
306 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 86
post4 challenge 28 93
Making an alias 7 82
"Black Box" Testing of Control System Software 2 26
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

25 Experts available now in Live!

Get 1:1 Help Now