Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

scroll logic please....

Posted on 2003-12-03
3
Medium Priority
?
372 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 60 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

927 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