Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Button Down Event

Status
Not open for further replies.

BrotherC

Programmer
Sep 29, 2002
25
CA

Hi, I would like to capture the event of a button being pressed down (CButton control class). Windows only sends a command message when the button is released if using OnClickButton().

If you could help out that would be great. Thanks !

 
Here's one way to do it: subclass CButton and add a new handler for OnLButtonDown. I did it like this and it seems to work:

Code:
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CRect rc;
	GetClientRect(&rc);
	if(rc.PtInRect(point))
	{
		// do stuff here
	}
	
	CButton::OnLButtonDown(nFlags, point);
}
 
You may also handle WM_NOTIFY messages. Many controls send WM_NOTIFY messagges when something happens with them.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top