15,980
社区成员




CRgn r;
r.CreateEllipticRgn(1,1,100,100);
if( r.PtInRegion(x,y))
{
}
else
{
}
BOOL CBitItem::CopyItemIndex(CDC * lpDesDC, int nIndex,
BOOL bSrc/* = TRUE*/,
POINT * lpOff /* = NULL*/)
{
ASSERT( nIndex < m_nItemNums );
ASSERT( lpDesDC != NULL );
if( lpDesDC == NULL || nIndex >= m_nItemNums )
return FALSE;
RECT rcSrc = {0, 0, 0, 0};
if( !this->GetRectByIndex(&rcSrc, nIndex) )
return FALSE;
return lpDesDC->BitBlt( (bSrc ? rcSrc.left : 0) + ((lpOff != NULL) ? lpOff->x : m_Offset.x),
(bSrc ? rcSrc.top : 0) + ((lpOff != NULL) ? lpOff->y : m_Offset.y),
rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top,
&m_ReadDC, rcSrc.left, rcSrc.top, SRCCOPY);
}
BOOL CBitItem::GetRectByIndex(LPRECT lpRect, int nIndex,
BOOL bSrc/* = TRUE*/,
POINT * lpOff/* = NULL*/)
{
//
// 1.0 Check the input value is validate...
if( lpRect == NULL || nIndex >= m_nItemNums )
return FALSE;
ASSERT( lpRect != NULL );
ASSERT( nIndex >= 0 );
//
// 2.0 Calculate the rectangle...
lpRect->left = (m_nDir == kBitHorizon) ? nIndex * m_nItemWidth : 0;
lpRect->top = (m_nDir == kBitVertical) ? nIndex * m_nItemHeight : 0;
lpRect->left += (bSrc ? 0 : ((lpOff != NULL) ? lpOff->x : m_Offset.x));
lpRect->top += (bSrc ? 0 : ((lpOff != NULL) ? lpOff->y : m_Offset.y));
lpRect->right = lpRect->left + m_nItemWidth;
lpRect->bottom = lpRect->top + m_nItemHeight;
return TRUE;
}
void CMySliderBar::OnLButtonDown(UINT nFlags, CPoint point)
{
m_isLbtDown = TRUE;
SetCapture();
if (m_blockRect.PtInRect(point)) //判断响应区域
{
m_isPressBlock = TRUE;
}
else
{
m_isPressBlock = FALSE;
}
if (!m_isPressBlock) //没有按住滑块,则计算当前的位置
{
m_pos = m_min + (m_max - m_min) * (point.x - m_crt.left) / m_crt.Width();
this->GetParent()->SendMessage(WM_MYSLIDER_SRCOLL, MAKEWPARAM(this->GetDlgCtrlID(), 0), MAKELPARAM(this->GetPos(), 0));
}
InvalidateParent();
CButton::OnLButtonDown(nFlags, point);
}