/*
函数:
gf_cmtopbu
功能:
将Centimeters转化成PBUs
参数:
dec adec_cm
boolean ab_axis True X-axis,False Y-axis
返回:
int li_rtn
对应:
1 cm = 0.3937 inch
1 inch = 2.54 cm
时间:
2004-01-08
*/
int li_rtn //返回值
long ll_dc //桌面dc
long ll_ppix //每英寸像素
ll_dc = GetDc(DC_SCREEN)
if ab_axis then
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSX)
li_rtn = PixelsToUnits(Integer(adec_cm * ll_ppix / 2.54),XPixelsToUnits!)
Else
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSY)
li_rtn = PixelsToUnits(Integer(adec_cm * ll_ppix / 2.54),YPixelsToUnits!)
End if
//For GetDeviceCaps
constant uLong LOGPIXELSX = 88 //Logical pixels per inch in X
constant uLong LOGPIXELSY = 90 //Logical pixels per inch in Y
//For GetDC
constant uLong DC_SCREEN = 0 //Entire Screen
//外部函数
//Retrieves device-specific information for the specified device
Function uLong GetDeviceCaps(long hdc,long nIndex) Library "gdi32"
//Retrieves a handle to a display device context
FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
//Releases a device context (DC), freeing it for use by other applications
FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"
/*
函数:
gf_pbutocm
功能:
将PBUs转化成Centimeters
参数:
int ai_pbu pbu长度值
boolean ab_axis True X,Flase Y
返回:
dec ldec_rtn
对应:
1 cm = 0.3937 inch
1 inch = 2.54 cm
时间:
2004-01-08
*/
dec{3} ldec_rtn //返回值
long ll_dc //桌面dc
long ll_ppix //每英寸像素
long ll_pixels //pbu对应的像素
ll_dc = GetDc(DC_SCREEN)
if ab_axis then
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSX)
ll_pixels = UnitsToPixels(ai_pbu,XUnitsToPixels!)
Else
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSY)
ll_pixels = UnitsToPixels(ai_pbu,YUnitsToPixels!)
End if