Improve company productivity with a Business Account.Sign Up

x
?
Solved

ScrollView and Document

Posted on 1998-08-17
11
Medium Priority
?
486 Views
Last Modified: 2013-11-20
Hello,

I have a document. Its size is set as follows:
CMyDoc::InitDoc()
m_sizeDoc = CSize (100,100);
I have a view. In its OnInitialUpdate I have the following code:
void CMyView::OnInitialUpdate()
{
...
GetParentFrame()->RecalcLayout();
ResizeParentToFit(TRUE);
CScrollView::OnInitialUpdate();
}
I am trying to prevent the frame window (view) from becoming larger than the doc size, which is 100,100.
I tried using WM_SIZE message to create CView::OnSize function that also has the following code:
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
GetParentFrame()->RecalcLayout();
ResizeParentToFit(TRUE);
}
I get an assertion error.
What should I do to prevent my frame window becoming larger than my doc size?
Where does my code go, which functions do I override ,etc.


}
0
Comment
Question by:Paullkha
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1320906
Process the following message in the frame
CWnd::OnGetMinMaxInfo (which is WM_GETMINMAXINFO )

Using this you can limit the size of the window.  You'll need to calculation border widths, caption allowances etc. by yourself but add this to the size and limit to that.  You can calculate the height of the caption etc. using GetSystemMetrics

0
 
LVL 2

Author Comment

by:Paullkha
ID: 1320907
In class wizard, it does not show that I can override this function.
I checked the VC++ help about OnGetMinMaxInfo. I do not need to worry about Minimizing or Maximizing.
Clarification:
I have a class derived from CScrollView. If I make my app full screen, I can RESIZE(grab the bottom left) my VIEW to be the full size of the app. This is not acceptable if my document size is smaller than my view size, at any given time. While I am resizing my view, I want to prevent its size from becoming larger than my doc size.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1320908
Unless I've completely misunderstood your question, this is the right message - it doesn't just apply to maximized/minimized windows - it also applies to tracking the size changes (when you drag the border of a window for example)

From the help - remarks section
The maximum tracking size is the largest window size that can be produced by using the borders to size the window. The minimum tracking size is the smallest window size that can be produced by using the borders to size the window.

Look at ptMinTrack size and ptMaxTrackSize in MINMAXINFO.

Good luck
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
LVL 1

Expert Comment

by:payn
ID: 1320909
ClassWizard (and the WizardBar and the context menu) aren't always right about what you can and can't (or should and shouldn't) overload.

Sometimes you have to manually overload a virtual function--or, worse, manually catch a Windows message--and then figure out such things as whether (and, if so, when) to call the base class version. Generally when the capablity was forgotten in ClassWizard the documentation is sketchy as well. Sometimes it helps to look at the actual MFC source for the parent class, but this doesn't always help.

In other words, just because ClassWizard tells you you can't overload OnGetMinMaxInfo or handle WM_GETMINMAXINFO doesn't mean you can't.

0
 
LVL 2

Author Comment

by:Paullkha
ID: 1320910
I might be out in left field. However, I added this code to my program:
MyView.cpp
void CMyView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
      lpMMI->ptMaxTrackSize = CPoint(100,100);
}
MyView.h
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);

I put a break point on CMyView::OnGetMinMaxSize. This procedure is NEVER(???)triggered.

What am I not following? (What about OnSize? This procedure does trigger my break point when I resize the view.)

0
 

Expert Comment

by:dvazquez
ID: 1320911
You need a message map entry too.
0
 
LVL 2

Author Comment

by:Paullkha
ID: 1320912
True. Thanks!
I added the following:
.Begin Message...      
ON_WM_GETMINMAXINFO()
.End Message...
However, it still behaves as stated
0
 
LVL 1

Expert Comment

by:payn
ID: 1320913
The short answer: You have to do this in your frame, not in your view.

As far as I can tell at a quick message-spying, the only windows that receive this in an MFC-built MDI app are the main frame and the MDI child frames; in an MFC-built SDI app, it's just the main frame.

Try moving the exact same code to your MDI child frame window and it should work.

You will need to adjust the desired view size (100x100) to include room for the border and the title bar in order to get the desired frame size.


0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1320914
payn said "The short answer: You have to do this in your frame, not in your view."

I said that 2 and half days ago in my original answer.  ditto on taking into account the captions and borders...
0
 
LVL 2

Author Comment

by:Paullkha
ID: 1320915
THANK YOU payn, for taking the time to analyze my code and find my error.

Answers2000, not everyone is as skilled as you in their understanding of MFC. It would have taken at most 4 lines of CODE to show me clearly what I was not understanding after I posted my comment showing CMyView::OnGetMinMaxInfo.
Answers2000, if you would like, please post an answer to this question so that I can give you points for providing me with the correct, albeit brief, original answer. If you are not interested, let me know so that I can give these points to payn.

I appreciate the help from both of you.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1320916
Thanks, sorry I wasn't clearer at the start, but after having my original answer rejected, I thought it better to keep a low profile :-)

I hadn't realized you had missed the message map entry, it didn't show up in your original fragment or comments, so it simply never occured to me that that was an additional problem area in your program.

Anyway I'm glad you've got it working now.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Watch the video to know the process of migration of Exchange or Office 365 mailboxes in absence of MS Outlook. It is an eminent tool which can easily migrate Public, Archive user mailboxes from one another Exchange server and Office 365. Kernel Migr…

607 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