Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Tag Archive for ‘SetViewPortOrg’

Custom Mapping Mode in VC++ Via MM_ISOTROPIC

Window and Viewport Extends vs Pixels

In the previous MFC Article, we examined how the Mapping Modes works while performing the drawing operation. In this example, we will see how we set the custom mapping modes. Our goal is below:

1) Set mapping mode so that the horizontal logical unit is 1 Centimeter (cm). Simply, 1 Unit = 1 cm in X axis.
2) Also, 1 Unit = 1 cm in Y Axis.
3) Positive X is towards left.
4) Positive Y is going Upwards.
5) The Drawing origin should be in screen center.

We can achieve the above goal by using the Custom Mapping mode MM_ISOTROPIC.

Continue Reading →

MFC Mapping Modes & Drawing Coordinate

MFC View-Port Origin and Window Origin

MFC supports two kinds of coordinate systems. One is Device Coordinate and the other one is Logical Coordinate. In device coordinate, we point out all in terms of pixels. In logical coordinate, we measure each unit in terms of Metric Standard or British Standard. How each unit maps to the logical measure is called the mapping. We can mention the mapping using the Mapping Modes. In MFC, having the knowledge of Drawing Origin is the key to draw in the Client Area the way you want.

In this Example, we will walk through the examples and demo videos, which will help us in learning the Mapping Modes and doing the MFC drawing using the device contexts. We will also try the ViewPort Origin and Window Origin and how to use them while drawing using MFC GDI APIs.

Continue Reading →