NCMsg_Test

UINT CNCMsgDlg::OnNcHitTest(CPoint point) 
{
	UINT nTest;
	RECT rect;
	GetWindowRect(&rect);
	
	//如果鼠标指针处于窗体边界5像素以内,可以拖动改变窗体大小。
	//如果鼠标指针处于窗体上部20像素以内,可以像标题栏那样移动窗体。
	if(point.x >= rect.left && point.x < rect.left + 4)			//鼠标X坐标在窗体左边界
	{
		if(point.y >= rect.top && point.y <= rect.top + 4)	
			nTest = HTTOPLEFT;									//鼠标在窗体左上角
		else if(point.y >= rect.bottom-4 && point.y <= rect.bottom)	
			nTest = HTBOTTOMLEFT;								//鼠标在窗体左下角
		else
			nTest = HTLEFT;										//鼠标在窗体左边界其它位置
	}
	else if(point.x <= rect.right && point.x >= rect.right - 4)	//鼠标X坐标在窗体右边界
	{
		if(point.y >= rect.top && point.y <= rect.top + 4)	
			nTest = HTTOPRIGHT;									//鼠标在窗体右上角
		else if(point.y >= rect.bottom-4 && point.y <= rect.bottom)	
			nTest = HTBOTTOMRIGHT;								//鼠标在窗体右下角
		else
			nTest = HTRIGHT;									//鼠标在窗体右边界其它位置
	}
	else if(point.y >= rect.top && point.y <= rect.top + 4)
	{
		nTest = HTTOP;											//鼠标在窗体上边界
	}
	else if(point.y >= rect.bottom - 4 && point.y < rect.bottom)
	{
		nTest = HTBOTTOM;										//鼠标
	}
	else if(point.y < rect.top + 20)
	{
		nTest = HTCAPTION;							//鼠标处于“标题栏”
	}
	else
	{
		nTest = HTCLIENT;							//默认情况,无特殊处理
	}
	return nTest;
}


阅读更多
个人分类: MFC
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭