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. zoom with graphic objects

zoom with graphic objects

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 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.
  • Y Offline
    Y Offline
    yang__lee
    wrote on last edited by
    #1

    Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya

    R C B 3 Replies Last reply
    0
    • Y yang__lee

      Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #2

      to display a DC with different dimensions that originals you could use CDC::StretchBlt.

      1 Reply Last reply
      0
      • Y yang__lee

        Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Depends of what the objects are. Please provide more information. If you draw them yourself, then draw them bigger, that's simple.

        1 Reply Last reply
        0
        • Y yang__lee

          Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya

          B Offline
          B Offline
          bob16972
          wrote on last edited by
          #4

          Here's a little to get you started. Start a new MFC/SDI app and plop this stuff in the appropriate locations. Set up menu/toolbar buttons for the zoomin/zoomout. Add some drawing code to your OnDraw and you should find that the drawing is fit_to_width in the view and it should be fit to width when printing. The rest is up to you. have fun... /////////////////////////////////////////////// //Constants const int MAX_SCALE = 20; // The maximum scale factor //CDocument members... protected: CSize m_DocSize; CSize CYourDoc::GetDocSize() const { return m_DocSize; } CYourDoc::CYourDoc() { // TODO: add one-time construction code here m_DocSize=CSize(2000,2800); } //CScrollView members... protected: int m_Scale; CYourView::CYourView() { // TODO: add construction code here m_Scale=1; // Set scale factor 1:1 SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values } void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { CScrollView::OnPrepareDC(pDC); // TODO: Add your specialized code here and/or call the base class // Set up the DC for the current scale factor int nExtentX; int nExtentY; CSize sizeDoc; CRect rectClient; // Allows the rectangle to include the bottom and rightmost logical unit // SetGraphicsMode(pDC->m_hDC,GM_ADVANCED); pDC->SetMapMode(MM_ISOTROPIC); // Allow scaling with aspect ratio preserved // Get pertinent rectangle data GetClientRect(&rectClient); sizeDoc=GetDocument()->GetDocSize(); sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments pDC->SetWindowExt(sizeDoc); // Window extent is size of document // Calculate viewport extent nExtentX=(int)(GetScale()*rectClient.Width()); nExtentY=(int)((GetScale()*((nExtentX*sizeDoc.cy)/(sizeDoc.cx)))); // What kind of device context do we have? if (pDC->IsPrinting()==TRUE) { // Printer Context. Allow printing to edge of context. No scaling. Margins? pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES)); } else { // Context is for screen pDC->SetViewportExt(nExtentX,nExtentY); } } int CYourView::GetScale() { return m_Scale; } void CYourView::SetScale(int nScaleFactor) { m_Scale=nScaleFactor; ResetScrollBars(); // Adjust scrollbars to new scale } void CYourView::OnUpdateViewZoomout(CCmdUI* pCmdUI) { // TODO: Add your command update UI han

          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