Solved

scroll logic please....

Posted on 2003-12-03
3
350 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 76
wordappend challenge 8 249
Thin secure Windows 10 5 116
Problem to App source 6 120
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

739 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