Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do i scale a DC?

How do i scale a DC?

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Miguel Lopes
    wrote on last edited by
    #1

    Hi, Im trying to scale a DC of a CWnd derivade (NOT CVIEW) and im not getting any success. Ive tried CDC::ScaleWindowExt(...) and CDC::ScaleViewportExt(...), among others. Also im using scroll bars in that window... does that affect it? Thanks in advanced

    A 1 Reply Last reply
    0
    • M Miguel Lopes

      Hi, Im trying to scale a DC of a CWnd derivade (NOT CVIEW) and im not getting any success. Ive tried CDC::ScaleWindowExt(...) and CDC::ScaleViewportExt(...), among others. Also im using scroll bars in that window... does that affect it? Thanks in advanced

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      What mapping mode are you using...? MM_ISOTROPIC...? "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

      M 1 Reply Last reply
      0
      • A alex barylski

        What mapping mode are you using...? MM_ISOTROPIC...? "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

        M Offline
        M Offline
        Miguel Lopes
        wrote on last edited by
        #3

        Ive already tried with MM_ISOTROPIC and MM_ANISOTROPIC and MM_TEXT, but no success so far. Right now, i dont have a limitation in using any of type of mapping mode. Maybe im using it wrong. U have a good example?

        A 2 Replies Last reply
        0
        • M Miguel Lopes

          Ive already tried with MM_ISOTROPIC and MM_ANISOTROPIC and MM_TEXT, but no success so far. Right now, i dont have a limitation in using any of type of mapping mode. Maybe im using it wrong. U have a good example?

          A Offline
          A Offline
          alex barylski
          wrote on last edited by
          #4

          One of my books shows exactly how this is accomplished...if I have some spare time in the next few i'll look into for you if someone hasn't answered it already... Cheers! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

          1 Reply Last reply
          0
          • M Miguel Lopes

            Ive already tried with MM_ISOTROPIC and MM_ANISOTROPIC and MM_TEXT, but no success so far. Right now, i dont have a limitation in using any of type of mapping mode. Maybe im using it wrong. U have a good example?

            A Offline
            A Offline
            alex barylski
            wrote on last edited by
            #5

            I managed to get this doing something like what you want (i think) but i'm gonna count on you to figure out how it works... :) OnPaint(): // make sure you call invalidate inside OnSize()

            CPaintDC dc(this); // device context for painting

            CRect rect;
            GetClientRect(rect);

            dc.SetMapMode(MM_ISOTROPIC); // Force ONE to ONE relationship
            dc.SetWindowExt(rect.Width(), rect.Height());

            // Start drawing
            dc.SetViewportOrg(0, 0);

            dc.LineTo(CPoint(200, 200));
            dc.LineTo(CPoint(0, 200));
            dc.LineTo(CPoint(200, 0));

            "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

            M 1 Reply Last reply
            0
            • A alex barylski

              I managed to get this doing something like what you want (i think) but i'm gonna count on you to figure out how it works... :) OnPaint(): // make sure you call invalidate inside OnSize()

              CPaintDC dc(this); // device context for painting

              CRect rect;
              GetClientRect(rect);

              dc.SetMapMode(MM_ISOTROPIC); // Force ONE to ONE relationship
              dc.SetWindowExt(rect.Width(), rect.Height());

              // Start drawing
              dc.SetViewportOrg(0, 0);

              dc.LineTo(CPoint(200, 200));
              dc.LineTo(CPoint(0, 200));
              dc.LineTo(CPoint(200, 0));

              "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

              M Offline
              M Offline
              Miguel Lopes
              wrote on last edited by
              #6

              k, i found how it can work, but it needs some changes: U have to call CDC::SetViewportExt(...) It works something like this: 1st SetMapMode(MM_ISOTROPIC) 2nd SetWindowExt(200,300) - carefull here, cause it sets the portion of the window to be considered 3rd SetViewportExt(rect.Width(), rect.Height()), to set the corresponding size of the "view" thanks for the guidance :cool:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups