Solved

Converting logic to device coordinates

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 114
either24  challenge 19 84
wait notify demo infinite loop 3 81
Fibonacci challenge 11 84
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now