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

发布时间 2023-04-16 09:31:50作者: 天子骄龙

 

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