# Thread: Getting document point co-ordinates

1. ## 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;
Info->Draw(&dc);
AfxMessageBox(showcoord);

}
}

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. ## MATH

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

SPH

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. 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.