Link to home
Start Free TrialLog in
Avatar of wenfei
wenfei

asked on

How to resize a view by calling SetScaleToFitSize()?

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?
Avatar of wenfei
wenfei

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of AlFa
AlFa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wenfei

ASKER

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);
}