Solved

How to resize a view by calling SetScaleToFitSize()?

Posted on 1998-02-04
3
1,148 Views
Last Modified: 2013-11-19
I want have the display in a CScrollView-derived view resize correspondingly when I resize the child window. I have called SetScaleToFitSize() in my routine as following:

void CMyView::OnInitialUpdate()
{
      CSize size = GetDocument()->GetSize();
      CClientDC dc(NULL);
      size.cx = MulDiv(size.cx, dc.GetDeviceCaps(LOGPIXELSX), 100);
      size.cy = MulDiv(size.cy, dc.GetDeviceCaps(LOGPIXELSY), 100);
//      SetScrollSizes(MM_TEXT, size);
      GetParentFrame()->RecalcLayout();
      SetScaleToFitSize(size);
}

The only result is the scroll bar disabled. The picture dose not change. When I resize the window, the picture dose not resize. Is there any other thing I have to do?

Further, I want the view and page is Landscape by default. How can I do that?
0
Comment
Question by:wenfei
  • 2
3 Comments
 

Author Comment

by:wenfei
ID: 1315588
Edited text of question
0
 
LVL 2

Accepted Solution

by:
AlFa earned 100 total points
ID: 1315589
Size must be teh size of your document in logical units.
SetScaleToFitSize will change the scale of your view in orderto display the whole doc. you won't have scrolllbar!

0
 

Author Comment

by:wenfei
ID: 1315590
I inserted dc.LPtoDP(&size). Before calling this function, size={767, 1055}, after calling, size={767, 1013}. And the display doesn't change. I thinks I am not on the right way. Could tell me the detail.
Thanks in advance.

void CMyView::OnInitialUpdate()
{
      CSize size = GetDocument()->GetSize();
      CClientDC dc(NULL);
      size.cx = MulDiv(size.cx, dc.GetDeviceCaps(LOGPIXELSX), 100);
      size.cy = MulDiv(size.cy, dc.GetDeviceCaps(LOGPIXELSY), 100);
//      SetScrollSizes(MM_TEXT, size);
      dc.LPtoDP(&size);
      GetParentFrame()->RecalcLayout();
      SetScaleToFitSize(size);
}

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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 575
only14 challenge 19 81
fix34  challenge 9 148
Not needed 13 120
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…
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…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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