Looks like MFC.
I want to ask about the dimension of 1 pixel in inch unit.
Doesn't matter. Windows can do it all for you.
Windows deals with drawing in terms of logical coordinates and device coordinates. Device coordinates are physical pixels on your monitor. Logical coordinates are a 'mapping system' used to position things in a window. All of the CDC class functions that accept coordinates (like CDC::FillRect) use logical coordinates.
By default, logical coordinates directly correspond to device coordinates (logical coordinate x,y corresponds to exactly one pixel). So, the code
Code:
brush.CreateSolidBrush(RGB(0, 0, 0));
CRect Rectangle(0, 0, 100, 200) ; //Simplified your coordinates for example clarity
dc.FillRect(&Rectangle , &brush);
will fill a rectangle that is 100 logical units by 200 logical units. Since, by default, logical coordinates and device coordinates are equal, the rectangle is 100 pixels by 200 pixels. You can, however, change the relationship between logical coordinates and device coordinates by using CDC::SetMapMode(int MappingMode). The Mapping Modes are:
Code:
MappingMode One logical unit equals
MM_TEXT 1 pixel
MM_LOMETRIC .1 mm
MM_HIMETRIC .01 mm
MM_LOENGLISH .01 in
MM_HIENGLISH .001 in
MM_TWIPS .0007 in
MM_ISOTROPIC user defined
MM_ANISTROPIC user defined
The code
Code:
brush.CreateSolidBrush(RGB(0, 0, 0));
CRect Rectangle(0, 0, 100, 200) ; //Simplified your coordinates for example clarity
dc.SetMapMode(MM_LOENGLISH);
dc.FillRect(&Rectangle , &brush);
will still fill a rectangle that is 100 logical units by 200 logical units. But, since we changed the mapping mode to MM_LOENGLISH, that rectangle is now 1 inch by 2 inches. If you measure the rectangle on your monitor, it should actually come out to 1x2 inches, though sometimes it's not exact due to differences in monitors, resolution, etc. If the device context is refering to a printer, it will come out exact because a printer has a fixed resolution (dpi).
Note that logical and device coordinates apply only to CDC class functions. The CRect class takes 4 integers as the corners for the rectangle, but CRect does not differentiate between logical or device coordinates; CDC::FillRect applies the 4 integers as logical coordinates.
fletch