MFC-PtInRect判断一个点是否在矩形中

 

win32API 

    
    HDC hdc = ::GetDC(m_hWnd);
    RECT rect = { 10,10,100,100 };
    POINT point = { 50,50 };


    BOOL b = PtInRect(&rect,point);//判断一个点是否在矩形中
    /*
    参数1:RECT*lprc  
    参数2:POINT  
    返回值:如果点在rect对象中,那么返回值为非零,否则返回值为0
    */

    CString str;
    str.Format(_T("b=%d"),b );
    ::OutputDebugString(str);

 

MFC 

    
    HDC hdc = ::GetDC(m_hWnd);
    CRect rect = { 10,10,100,100 };
    CPoint point = { 50,50 };


    BOOL b = rect.PtInRect(point);//判断一个点是否在矩形中
    /*
      
    返回值:如果点在rect对象中,那么返回值为非零,否则返回值为0
    */

    CString str;
    str.Format(_T("b=%d"),b );
    ::OutputDebugString(str);

 

 

 

 

 

 

posted @ 2023-04-16 09:29  天子骄龙  阅读(64)  评论(0)    收藏  举报