return TRUE;
}
LRESULT OnLButtonDown( HWND hWnd, UINT nFlags, CPoint point ) //鼠標(biāo)左鍵按下時(shí)處理函數(shù)
{
m_State = bsDown; //設(shè)置按鈕狀態(tài)
SetCapture(hWnd); //捕獲鼠標(biāo)
SetFocus(hWnd); //設(shè)置焦點(diǎn)
w InvalidateRect(hWnd,NULL,TRUE); //重繪窗口區(qū)域
return TRUE;
}
LRESULT OnLButtonUp( HWND hWnd, UINT nFlags, CPoint point ) //鼠標(biāo)左鍵抬起時(shí)處理函數(shù)
{
if( m_State != bsNormal ) //判斷按鈕狀態(tài)
{
m_State = bsNormal; //設(shè)置按鈕狀態(tài)
ReleaseCapture(); //釋放鼠標(biāo)
InvalidateRect(hWnd,NULL,TRUE); //重繪窗口區(qū)域
//發(fā)送WM_COMMAND消息
x SendMessage( GetParent(hWnd), WM_COMMAND, GetDlgCtrlID(hWnd), (LPARAM) (hWnd) );
}
return TRUE;
}
LRESULT LoseFocus(HWND hWnd) //失去焦點(diǎn)時(shí)處理函數(shù)
{
m_State = bsNormal; //設(shè)置按鈕狀態(tài)
InvalidateRect(hWnd,NULL,TRUE); //重繪窗口區(qū)域
SendMessage( hWnd, WM_KILLFOCUS, (long)hWnd, 0); //發(fā)送WM_KILLFOCUS消息
return TRUE;
}
LRESULT OnMouseMove(HWND hWnd, UINT nFlags, CPoint point ) //鼠標(biāo)移動(dòng)時(shí)處理函數(shù)
{
HRGN hRgn = CreateRectRgn( 0, 0, 0, 0 ); //創(chuàng)建矩形區(qū)域
GetWindowRgn( hWnd,hRgn ); //獲得窗口區(qū)域
BOOL ret = PtInRegion( hRgn, point.x, point.y ); //判斷鼠標(biāo)是否在窗口區(qū)域中
if( ret )
{
if( m_State == bsDown) //判斷按鈕是否按下
return TRUE;
if( m_State != bsHot ) //判斷按鈕是否熱點(diǎn)
{
m_State = bsHot; //設(shè)置按鈕狀態(tài)
InvalidateRect(hWnd,NULL,TRUE); //重繪窗口區(qū)域
UpdateWindow(hWnd); //更新顯示窗口
SetCap tare(hWnd); //捕獲鼠標(biāo)
}
}
else
{
m_State = bsNormal; //設(shè)置按鈕狀態(tài)
InvalidateRect(hWnd,NULL,TRUE); //重繪按鈕區(qū)域
ReleaseCapture(); //釋放鼠標(biāo)
}
DeleteObject( hRgn );
return TRUE;
}
};