zoom with graphic objects
-
Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya
-
Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya
Depends of what the objects are. Please provide more information. If you draw them yourself, then draw them bigger, that's simple.
-
Hi, How can I implement zoom in and outfor graphic objects in the view. These are not bitmaps. ANy links? thanks Leya
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