BOOL CWnd::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->hwnd== m_button.m_hWnd &&pMsg->message==WM_MOUSEMOVE) { int pos=0; } return CWnd::PreTranslateMessage(pMsg); }
// Get the current mouse position CPoint pointMouse; GetCursorPos(&pointMouse); // Transform into client coordinates ScreenToClient(&pointMouse); CRect rect; yourButtom.GetClientRect(&rect); if (rect.PtInRect(point)) { // mouse is over button }
可以用SWITCH来判断移动了哪个按钮的么在 OnMouseMove函数里
{
// TODO: 在此添加消息处理程序代码和/或调用默认值 if(point.x>777 && point.x<799 && point.y>1 && point.y<22)//此区域是关闭键
{
m_mb_close.state = BUTTON_STATE_STOP;
} CDialog::OnMouseMove(nFlags, point);
}
SWITCH (?) 现在就是找不到问号是什么啊
ScreenToClient(rect);
根据rect判断就可以了
SWITCH (?) 现在就是找不到问号是什么啊/////////////////////////////////////////////////////////////////////////////你那个应该是判断控件焦点的吧?
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->hwnd== m_button.m_hWnd &&pMsg->message==WM_MOUSEMOVE)
{
int pos=0;
}
return CWnd::PreTranslateMessage(pMsg);
}
CPoint pointMouse;
GetCursorPos(&pointMouse);
// Transform into client coordinates
ScreenToClient(&pointMouse);
CRect rect;
yourButtom.GetClientRect(&rect);
if (rect.PtInRect(point))
{
// mouse is over button
}