Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Converting logic to device coordinates

Posted on 2000-04-14
1
Medium Priority
?
339 Views
Last Modified: 2013-11-20
I want to set center of coordinate system device to center of client device. Then I want to draw line to point where I click with mouse on client device. Under this is code of my program. Can You explain me where I make logical error?

Thank you and sorry for my bad english!


void CShowStringView::OnLButtonUp(UINT nFlags, CPoint point)
{
      CClientDC dc(this);
      int c = dc.SetMapMode(MM_LOMETRIC);
      CRect rc;
      GetClientRect(rc);
      
      
      CPoint p1(rc.right/2,rc.bottom/2);
      SetViewportOrgEx ( dc, p1.x,p1.y, NULL);
      OnPrepareDC(&dc);
      
      CPoint p(0,0);
      dc.LPtoDP(&p);
      dc.MoveTo(p);
      dc.LineTo(point);
      CPoint a = dc.GetViewportOrg();
      dc.DPtoLP(&a);

        CView::OnLButtonUp(nFlags, point);
}
0
Comment
Question by:avram032300
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
RONSLOW earned 150 total points
ID: 2716262
just do it all in client coordinates (which is what comes in to LButtonUp) ie. like this:

void CShowStringView::OnLButtonUp(UINT nFlags, CPoint point)
{
  CRect rc;
  GetClientRect(rc);
  CPoint p1(rc.right/2,rc.bottom/2);
  CClientDC dc(this);
  dc.MoveTo(p1);
  dc.LineTo(point);
  CView::OnLButtonUp(nFlags, point);
}
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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