Thread: Getting document point co-ordinates

  1. #1

    Unhappy Getting document point co-ordinates

    I'm building an application using the mfc wizard in visual c++ 6. I've set the document to the size of an a3 page which takes up more space than is available on screen. The x, y co-ordinates for the document are 1700, 1122. I've got an A3 touch pad with x, y co-ordinates of 2500, 2000 and I want to map the pad to the document. I've used this code to draw a rectangle on the screen:

    void CProjectView::OnLButtonDown(UINT nFlags, CPoint point) {

    CPoint AP;
    CString showcoord;
    char* s1 = new char[7];

    _itoa(point.x, s1, 10);
    showcoord += s1;
    showcoord += " , ";
    _itoa(point.y, s1, 10);
    showcoord += s1;

    if (drawpoint) {
    CClientDC dc(this);
    AP.x = (point.x)-20;
    AP.y = (point.y)-20;
    InfoPoint *Info = GetDocument()->AddPoint(point, AP);


    The AddPoint function draws the rectangle on the screen but the co-ordinates in the message box show the point co-ordinates for what can be seen on screen, not the whole document. eg. when I go the bottom-right hand corner and click, the co-ordinates pop up with 960, 620 instead of 1700, 1122. Do you know a way to return the document co-ordinate of the point clicked instead of the screen co-ordinate?

  2. #2
    Registered User minime6696's Avatar
    Join Date
    Aug 2001

    Lightbulb MATH

    Think.... Math.... Numbers....


    P.S. I dont mean to be con-decending... just every tiem I had a prob liek this I worked it out on paper... I jsut see too much of this on the board now days... sorry.

  3. #3
    It's not just the math I'm having a problem with. I know that if the to map the document to the pad the math is:
    xco-ord = x * (1700/2500)
    yco-ord = y * (1122/2000)
    My problem is with what's shown on the screen. eg. when the document is first opened and I click on the bottom right of the view then the co-ords are 960, 620. If I then scroll across and down the screen and click the bottom right of the view then the co-ords are still 960, 620. Then if I don't scroll but minimize and click the bottom right of the view then the co-ords show 600, 400. I want the CClientDC to match the CProjectDoc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help realy needed
    By ZohebN in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2008, 09:37 AM
  2. Getting a floating point exception
    By SnertyStan in forum C Programming
    Replies: 13
    Last Post: 03-25-2008, 11:00 AM
  3. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  4. floating point binary program, need help
    By ph34r me in forum C Programming
    Replies: 4
    Last Post: 11-10-2004, 07:10 AM
  5. How to decide if four lines form a square?
    By Koedoe in forum C++ Programming
    Replies: 6
    Last Post: 10-01-2002, 10:38 AM