return TRUE;
}
LRESULT OnLButtonDown( HWND hWnd, UINT nFlags, CPoint point ) //鼠标左键按下时处理函数
{
m_State = bsDown; //设置按钮状态
SetCapture(hWnd); //捕获鼠标
SetFocus(hWnd); //设置焦点
w InvalidateRect(hWnd,NULL,TRUE); //重绘窗口区域
return TRUE;
}
LRESULT OnLButtonUp( HWND hWnd, UINT nFlags, CPoint point ) //鼠标左键抬起时处理函数
{
if( m_State != bsNormal ) //判断按钮状态
{
m_State = bsNormal; //设置按钮状态
ReleaseCapture(); //释放鼠标
InvalidateRect(hWnd,NULL,TRUE); //重绘窗口区域
//发送WM_COMMAND消息
x SendMessage( GetParent(hWnd), WM_COMMAND, GetDlgCtrlID(hWnd), (LPARAM) (hWnd) );
}
return TRUE;
}
LRESULT LoseFocus(HWND hWnd) //失去焦点时处理函数
{
m_State = bsNormal; //设置按钮状态
InvalidateRect(hWnd,NULL,TRUE); //重绘窗口区域
SendMessage( hWnd, WM_KILLFOCUS, (long)hWnd, 0); //发送WM_KILLFOCUS消息
return TRUE;
}
LRESULT OnMouseMove(HWND hWnd, UINT nFlags, CPoint point ) //鼠标移动时处理函数
{
HRGN hRgn = CreateRectRgn( 0, 0, 0, 0 ); //创建矩形区域
GetWindowRgn( hWnd,hRgn ); //获得窗口区域
BOOL ret = PtInRegion( hRgn, point.x, point.y ); //判断鼠标是否在窗口区域中
if( ret )
{
if( m_State == bsDown) //判断按钮是否按下
return TRUE;
if( m_State != bsHot ) //判断按钮是否热点
{
m_State = bsHot; //设置按钮状态
InvalidateRect(hWnd,NULL,TRUE); //重绘窗口区域
UpdateWindow(hWnd); //更新显示窗口
SetCap tare(hWnd); //捕获鼠标
}
}
else
{
m_State = bsNormal; //设置按钮状态
InvalidateRect(hWnd,NULL,TRUE); //重绘按钮区域
ReleaseCapture(); //释放鼠标
}
DeleteObject( hRgn );
return TRUE;
}
};