Solved

Converting logic to device coordinates

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET how to use the Vertical ScrollBar 5 103
Expand macro to include alternate header placement and naming 5 71
countEvens challenge 2 98
Annoying "thing" blocks my view 4 99
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

785 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