在对话框上创建了两个按钮控件,这段代码的功能是鼠标移动到其中一个控件上面时隐藏这个控件,同时显示另外一个按钮控件。其中m_rect1和m_rect2为两个CRect变量
目前的问题是只有鼠标移动到控件的bottom和right上时才能隐藏控件,其余地方均无反应,不知为何
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
GetDlgItem(IDC_BUTTON1)->GetWindowRect(&m_rect1);
GetDlgItem(IDC_BUTTON2)->GetWindowRect(&m_rect2);
ClientToScreen(&point);
if((m_rect1.left<=point.x)&&(point.x<=m_rect1.right)&&(m_rect1.top<=point.y)&&(point.y<=m_rect1.bottom))
{
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOWNORMAL);
}
else if((m_rect2.left<=point.x)&&(point.x<=m_rect2.right)&&(m_rect2.top<=point.y)&&(point.y<=m_rect2.bottom))
{
GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_SHOWNORMAL);
}
CDialog::OnMouseMove(nFlags, point);
}