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;
|