Solved

Converting logic to device coordinates

Posted on 2000-04-14
1
333 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 50 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

635 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