Solved

scroll logic please....

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 75
Named range not carried over 10 63
substring method in java 1 122
if loop in java 3 142
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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