Source code 1
/ * Function:
Convert logical position to the location of the final physical coordinate space
Parameter:
HDC --- Space in the logic coordinate to be converted
LPPOINT --- The logical point of the to-convert is the logical point before conversion, and the conversion is a hieraser millimeter.
NCOUNT ---- Number of todped
RetValue:
True Or False
History:
2003-10-25 11: 13 * / void getPhysicalPosition (HDC HDC, LPPOINT LPPOINT, INT NCOUNT) {Point OriginPoint;
Int widthmm = getDeviceCaps (HDC, HORZSIZE); int Heightmm = getDeviceCaps (HDC, Vertsize);
Int widthres = getDeviceCaps (HDC, Horzres); int Heightres = getDeviceCaps (HDC, Vertres);
LPTODP (HDC, LPPOINT, NCOUNT);
Getdcorgex (HDC, & Originpoint);
For (int i = 0; i LPPOINT [I] .x = lppoint [i] .x * widthmm / widthres; lppoint [i] .y = lpoint [i] .y * heightmm / heightres; } Source code 2 / * function: Our own logical coordinates to device coordinates functions * / BOOL MyLPtoDP (HDC hdc, // handle to device context LPPOINT lpPoints, // array of points int nCount // count of points in array) {int graphicsMode = GetGraphicsMode ( HDC); If (graphicsmode == gm_advanced) // Handle the situation of the world coordinate system is enabled {XForm Curform; GetWorldTransform (HDC, & Curform); For (int i = 0; i LPPOINTS [i] .x = (int) xpage; lppoints [i] .y = (int) ypage;}} Point Pointorgview, Pointorgwin; Size Winsize, ViewSize // Get the origin and range of the window, the origin and range of GetViewportorgex (HDC, & PointorgView); GetViewPortextex (HDC, & viewsize); GetWindoworgex (HDC, & Pointorgwin); GetWindowExtex (HDC, & Winsize); / / According to Formula 2, the page coordinate space to the conversion for the device coordinate space (INT i = 0; I Return True;}