CRect
CDataProcessCtrl::GetRect( const string& strWinName, int iRectId, int iAnchorType)
{
CRect rcTemp;
(void)GetRect( strWinName, iRectId, rcTemp);
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
double iMaxCx = (double)cx/(double)STD_SCREEN_CX;
double iMaxCy = (double)cy/(double)STD_SCREEN_CY;
double dScale = iMaxCy - iMaxCx;
double iTemp = 0;
int iSrcWidth = rcTemp.Width();
int iSrcHeight = rcTemp.Height();
if( cx > cy )
{
iTemp = (double)rcTemp.left * iMaxCx;
rcTemp.left =(int)iTemp;
iTemp = (double)rcTemp.right * iMaxCx;
rcTemp.right =(int)iTemp;
iTemp = (double)rcTemp.top * iMaxCy;
rcTemp.top =(int)iTemp;
iTemp = (double)rcTemp.bottom * iMaxCy;
rcTemp.bottom =(int)iTemp;
return rcTemp;
}
//比例相等
if( dScale == 0 )
{
iTemp = (double)rcTemp.left * iMaxCx;
rcTemp.left =(int)iTemp;
iTemp = (double)rcTemp.right * iMaxCx;
rcTemp.right =(int)iTemp;
iTemp = (double)rcTemp.top * iMaxCy;
rcTemp.top =(int)iTemp;
iTemp = (double)rcTemp.bottom * iMaxCy;
rcTemp.bottom =(int)iTemp;
}
//CY比例大于
CX,竖屏情况,以CX为基准
else if( dScale > 0 )
{
// 居中对齐,
Y坐标按Y方向做不等比缩放
if( iAnchorType & ANCHOR_VCENTER ) {
iTemp = (double)rcTemp.top * iMaxCy;
rcTemp.top =(int)iTemp;
}
// 靠顶对齐,
Y坐标按X方向做等比缩放
else if( iAnchorType & ANCHOR_TOP )
{
iTemp = (double)rcTemp.top * iMaxCx;
rcTemp.top =(int)iTemp;
}
//X坐标做等比缩放
iTemp = (double)rcTemp.left * iMaxCx;
rcTemp.left =(int)iTemp;
// 长宽做等比拉伸
rcTemp.right = (int)(rcTemp.left + (double)(iSrcWidth * iMaxCx));
rcTemp.bottom = (int)(rcTemp.top + (double)(iSrcHeight * iMaxCx));
}
//CY比例小于
CX,横屏情况,已CY为基准
else
{
// 居中对齐,
X坐标按X方向做不等比缩放
if( iAnchorType & ANCHOR_HCENTER ) {
iTemp = (double)rcTemp.left * iMaxCx;
rcTemp.left =(int)iTemp;
}
// 靠顶对齐,
Y坐标按X方向做等比缩放
else if( iAnchorType & ANCHOR_LEFT )
{
iTemp = (double)rcTemp.left * iMaxCy;
rcTemp.left =(int)iTemp;
}
// Y坐标只做等比拉伸
iTemp = (double)rcTemp.top * iMaxCy;
rcTemp.top =(int)iTemp;
// 长宽做等比拉伸
rcTemp.right = (int)(rcTemp.left + (double)(iSrcWidth * iMaxCy));
rcTemp.bottom = (int)(rcTemp.top + (double)(iSrcHeight * iMaxCy));
}
return rcTemp;
}
|
rcTip.left = rc.CenterPoint().x - sizeTip.cx / 2;
rcTip.top = rc.CenterPoint().y - sizeTip.cy / 2;
rcTip.right = rc.CenterPoint().x + sizeTip.cx / 2;
rcTip.bottom = rc.CenterPoint().y + sizeTip.cy / 2;
|
rcTip.left = rc.CenterPoint().x - sizeTip.cx / 2;
rcTip.top = rc.CenterPoint().y - sizeTip.cy / 2;
rcTip.right = rcTip.left + sizeTip.cx;
rcTip.bottom = rcTip.top + sizeTip.cy;
|