Solved

scroll logic please....

Posted on 2003-12-03
3
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses

623 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