MFC's Coordinate System?
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: MFC's Coordinate System?

1. Member
Join Date
Jun 2013
Posts
32

## MFC's Coordinate System?

Hello,

I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:

Code:
```double CompassDegreesToRadians(double compassDegrees)
{
return((PI / 2.0f) - (compassDegrees * PI / 180.0f));
}

// Make pen
CPen penRed;
penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));

// Test Angles
CRect rectClient;
GetClientRect(rectClient);
float angle1 = 0;
int radius = rectClient.CenterPoint().x;
dc.MoveTo(rectClient.CenterPoint());
dc.LineTo(x1, y1);```
Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:

Code:
```             180 -y
|
|
-x 270---------------- 90 +x
|
|
0 +y```
This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):

Code:
```               0 +y
|
|
-x 270---------------- 90 +x
|
|
180 -y```
Last edited by clow; October 11th, 2013 at 04:38 PM.

2. Elite Member Power Poster
Join Date
Aug 2000
Location
New York, NY, USA
Posts
5,656

## Re: MFC's Coordinate System?

If you do not like this coordinate system, change your mapping mode from MM_TEXT to something like MM_HIMETRIC (or MM_HIENGLISH).

3. Member
Join Date
Jun 2013
Posts
32

## Re: MFC's Coordinate System?

Hello,

Yeah I saw those functions, and tried MM_LOENGLISH, but when I did that, nothing appeared on the screen. How would I calculate the coordinate system transform by normal C++ code between the two systems I listed above?

Thanks!

4. ## Re: MFC's Coordinate System?

Or just have resultant y1 coordinate multiplied by -1.

5. Elite Member Power Poster
Join Date
Aug 2000
Location
New York, NY, USA
Posts
5,656

## Re: MFC's Coordinate System?

Originally Posted by clow
...tried MM_LOENGLISH, but when I did that, nothing appeared on the screen.
With those mapping modes, your (0,0) point is in the LOWER-LEFT corner of the window, X grows to the right and Y - up.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Click Here to Expand Forum to Full Width