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. Scrolling size on zooming

Scrolling size on zooming

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
2 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.
  • A Offline
    A Offline
    Anu_Bala
    wrote on last edited by
    #1

    Hi, I got one CZoomView sample file form code project.Actually i want zoom fucntion in my applcaiton for every view.In tht,initially when i set scrollposition,extra window is appearing. For example,in OnDraw(),i set background of window as black

    CRect mClientArea;
    GetClientRect(&mClientArea);
    pDC->FillRect(&mClientArea,&CBrush(RGB(0,0,0)));

    I set scroolsize as

    m_layout.cx = GetSystemMetrics( SM_CXSCREEN );
    m_layout.cy = GetSystemMetrics( SM_CYSCREEN );
    m_page.cx = m_layout.cx/2; m_page.cy = m_layout.cy/2;
    m_line.cx = m_layout.cx/50; m_line.cy = m_layout.cy/50;
    SetScrollSizes(MM_TEXT, m_layout, m_page, m_line);

    What happended is after execution,when i scroll the horizonatal or vertical scrolls,the window is scrolling more than actual window rect. More white screen is appearing apart for black background.How can i avoid that? Because while zooming,if user move the scrolls,then extra empty window will appear.i want to avoid that.

    Anu

    K 1 Reply Last reply
    0
    • A Anu_Bala

      Hi, I got one CZoomView sample file form code project.Actually i want zoom fucntion in my applcaiton for every view.In tht,initially when i set scrollposition,extra window is appearing. For example,in OnDraw(),i set background of window as black

      CRect mClientArea;
      GetClientRect(&mClientArea);
      pDC->FillRect(&mClientArea,&CBrush(RGB(0,0,0)));

      I set scroolsize as

      m_layout.cx = GetSystemMetrics( SM_CXSCREEN );
      m_layout.cy = GetSystemMetrics( SM_CYSCREEN );
      m_page.cx = m_layout.cx/2; m_page.cy = m_layout.cy/2;
      m_line.cx = m_layout.cx/50; m_line.cy = m_layout.cy/50;
      SetScrollSizes(MM_TEXT, m_layout, m_page, m_line);

      What happended is after execution,when i scroll the horizonatal or vertical scrolls,the window is scrolling more than actual window rect. More white screen is appearing apart for black background.How can i avoid that? Because while zooming,if user move the scrolls,then extra empty window will appear.i want to avoid that.

      Anu

      K Offline
      K Offline
      kylur
      wrote on last edited by
      #2

      Anu, Try this: // header file: "MyScrollView.h"

      #pragma once

      class CDoc;
      class CMyScrollView : public CScrollView
      {
      DECLARE_DYNCREATE(CMyScrollView)
      DECLARE_MESSAGE_MAP()

      public:
      CMyScrollView();
      virtual ~CMyScrollView();

      CDoc\* GetDocument();
      

      protected:
      virtual void OnDraw(CDC* pDC);
      virtual void OnInitialUpdate();

      private:
      int Height;
      int Width;
      CBitmap* Bitmap;
      CDC* MemDC;
      };

      // implementation file: "MyScrollView.cpp"

      #include "stdafx.h"
      #include "MyScrollView.h"

      IMPLEMENT_DYNCREATE(CMyScrollView, CScrollView)
      BEGIN_MESSAGE_MAP(CMyScrollView, CScrollView)
      END_MESSAGE_MAP()

      CMyScrollView::CMyScrollView() :
      Bitmap(new CBitmap), Width(1000), Height(200), MemDC(new CDC)
      {
      MemDC->CreateCompatibleDC(NULL);
      }

      CMyScrollView::~CMyScrollView()
      {
      delete Bitmap;
      delete MemDC;
      }

      CDoc* CMyScrollView::GetDocument()
      { return (CDoc*)m_pDocument; }

      void CMyScrollView::OnInitialUpdate()
      {
      CScrollView::OnInitialUpdate();

      GetParentFrame()->SetWindowText("CMyScrollView");
      
      CClientDC dc(this);
      Bitmap->CreateCompatibleBitmap(&dc, Width, Height);
      Bitmap->SetBitmapDimension(Width, Height);
      
      CBitmap\* OldBitmap = MemDC->SelectObject(Bitmap);
      
      MemDC->PatBlt(0, 0, Width, Height, BLACKNESS);
      CPen WhitePen(PS\_SOLID, 1, RGB(255,255,255));
      CPen\* 	OldPen = MemDC->SelectObject(&WhitePen);
      MemDC->MoveTo(0, 0);				// ie top left
      MemDC->LineTo(Width, Height);		// ie bottom right
      MemDC->MoveTo(Width, 0);			// ie top right
      MemDC->LineTo(0, Height);			// ie bottom left
      MemDC->SelectObject(OldPen);
      
      CPen RedPen(PS\_SOLID, 1, RGB(255,0,0));
      OldPen = MemDC->SelectObject(&RedPen);
      MemDC->Rectangle(0,0,10,10);		// red rect in top left
      MemDC->SelectObject(OldPen);
      
      CPen GreenPen(PS\_SOLID, 1, RGB(0,255,0));
      OldPen = MemDC->SelectObject(&GreenPen);
      MemDC->Ellipse(Width-20, Height-20, Width, Height);	// green circle bottom right
      MemDC->SelectObject(OldPen);
      
      CRect Rect(0,Height-20,20,Height);
      CBrush Brush(RGB(0,0,255));
      MemDC->FillRect(Rect, &Brush);		// blue rect in bottom left
      
      MemDC->SelectObject(OldBitmap);
      
      SetScrollSizes(MM\_TEXT, CSize(Width, Height));
      ResizeParentToFit(TRUE);
      

      }

      void CMyScrollView::OnDraw(CDC* pDC) // works!
      {
      if (Bitmap)
      {
      pDC->SetStretchBltMode( COLORONCOLOR );

      	CBitmap\* OldBitmap = MemDC->SelectObject(Bitmap);
      
      	pDC->BitBlt( // l, t, w, h
      		0, 0, Width, Height,
      
      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