Solved

scroll logic please....

Posted on 2003-12-03
3
332 Views
Last Modified: 2013-11-20
hi..

void CEditorView::OnInitialUpdate()
{
      CScrollView::OnInitialUpdate();

      //CSize sizeTotal;
      // TODO: calculate the total size of this view
      //sizeTotal.cx = sizeTotal.cy = 100;
      //SetScrollSizes(MM_TEXT, sizeTotal);
      SetScrollSizes(MM_LOENGLISH, CSize(2020, 1020));
}

in the above code..i wanna know when i set the mapping mode to MM_LOENGLISH, the param that i supply...are they depicted in mapping mode as i entered??or are they changed to mapping mode params and then entered??
for eg..above is the mapping mode taken in, is it exacly 2020 and 1020 in MM_LOENGLISH???
or is it converted to LOENGLISH and the value has changed to LOENGLISH and is no longer 2020 by 1020???
i gues its a more of my understanding prob...can someone pls help and gimme an explanation pls...???tks....
(my view i derived from CScrollView)
0
Comment
Question by:joseph-r-thomas
  • 2
3 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 9869710
The mapping mode tells the window what units the numbers you passed are in.  So it should take the 2020 and 1020 units, assume they are MM_LOENGLISH and convert them to whatever Windows uses internally (probably pixels).

Hope this helps.
0
 

Author Comment

by:joseph-r-thomas
ID: 9871779
actually what i amtrying to say in my question is...
so does it uethe EXACT SPECIFIED PARAMS and use the exact same ones in MM_LOENGLISH????
or does it change them....???????
to MM_LOENGLISH values, so taht they are no longer the exact figures that i specified.???
0
 
LVL 11

Accepted Solution

by:
KurtVon earned 20 total points
ID: 9874545
I'm not sure I understand.

Here's the function as defined in MFC 4.2:

void CScrollView::SetScrollSizes(int nMapMode, SIZE sizeTotal,
      const SIZE& sizePage, const SIZE& sizeLine)
{
      ASSERT(sizeTotal.cx >= 0 && sizeTotal.cy >= 0);
      ASSERT(nMapMode > 0);
      ASSERT(nMapMode != MM_ISOTROPIC && nMapMode != MM_ANISOTROPIC);

      int nOldMapMode = m_nMapMode;
      m_nMapMode = nMapMode;
      m_totalLog = sizeTotal;

      //BLOCK: convert logical coordinate space to device coordinates
      {
            CWindowDC dc(NULL);
            ASSERT(m_nMapMode > 0);
            dc.SetMapMode(m_nMapMode);

            // total size
            m_totalDev = m_totalLog;
            dc.LPtoDP((LPPOINT)&m_totalDev);
            m_pageDev = sizePage;
            dc.LPtoDP((LPPOINT)&m_pageDev);
            m_lineDev = sizeLine;
            dc.LPtoDP((LPPOINT)&m_lineDev);
            if (m_totalDev.cy < 0)
                  m_totalDev.cy = -m_totalDev.cy;
            if (m_pageDev.cy < 0)
                  m_pageDev.cy = -m_pageDev.cy;
            if (m_lineDev.cy < 0)
                  m_lineDev.cy = -m_lineDev.cy;
      } // release DC here

      // now adjust device specific sizes
      ASSERT(m_totalDev.cx >= 0 && m_totalDev.cy >= 0);
      if (m_pageDev.cx == 0)
            m_pageDev.cx = m_totalDev.cx / 10;
      if (m_pageDev.cy == 0)
            m_pageDev.cy = m_totalDev.cy / 10;
      if (m_lineDev.cx == 0)
            m_lineDev.cx = m_pageDev.cx / 10;
      if (m_lineDev.cy == 0)
            m_lineDev.cy = m_pageDev.cy / 10;

      if (m_hWnd != NULL)
      {
            // window has been created, invalidate now
            UpdateBars();
            if (nOldMapMode != m_nMapMode)
                  Invalidate(TRUE);
      }
}

As you can see, it calls LPtoDP to convert the MM_LOENGLISH measurements to pixels on the display device.  Since this is as accurate as the device is capable of anyways, one could argue that this is exactly the same.  Of course, there is no way to convert one set of units to another like that unless the conversion is guaranteed to go int->int (which in this case it isn't).

So, no, it isn't exact mathematically, but it is as accurate as the display is capable of showing which might as well be exact.

Hope this helps.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This video discusses moving either the default database or any database to a new volume.

747 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

16 Experts available now in Live!

Get 1:1 Help Now