ScreenToClient
该函数实现Screen(屏幕坐标) 到 Client(客户区坐标)的转换。也就是说这个函数可以把在屏幕上鼠标的坐标转换为程序的客户区的坐标。
可以配合CRect::PtInRect(ptClient)使用来判断某个坐标是否在某个区域内。
CPoint ptClient = point;
ScreenToClient(&ptClient);
if (m_rectIndex.PtInRect(ptClient) == false) {
return;
}
GetClientRect
该函数获取窗口客户区的大小。注意一下:窗口的客户区为窗口中除标题栏、菜单栏之外的地方。
CRect rc;
GetClientRect( &rc );
int nWidth = rc.Width();
int nHeight = rc.Height();