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!

mouse event functions in vc++ 1

Status
Not open for further replies.

oinky

Programmer
Oct 29, 2001
45
US
Hi I am having a problem with the calling of this function:

OnLButtonUp(UINT nFlags, CPoint point)

My GUI has a display area with some controls on it such as buttons, edit boxes etc. I am trying to trap the event when the user clicks the left mouse button and when the user lets go of the left mouse button. Things work fine if the user clicks on the display area but not if they click on a control. When the user clicks on a control, the OnLButtonDown and OnLbuttonUp functions are not being called. Can someone tell me why and how to fix this? Thanks.
 
Your controls have separate handling for events because the controls are usually separate "Windows" from the parent dialog. Open class wizard and ensure the first tab along the top is selected. In the box on the left you should see your dialog name. Below that will be a list of additional items such as the dialog's controls and menu items, etc. CLick on one of the control's resource IDs in the list and in the box on the right it will give you a list of the events available that you can create functions for. NB: many controls will not include a LBUTTONDOWN event handler.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
o i get it now. Thanks. i guess there are some controls in mfc where i just cant code up what the mouse event clicks.
 
Well actually you can.... but it's not a small job. Basically, you can create yoiur own ActiveX based control using one of the standard MFC controls as a starting point. You can add the message handlers you want for the "custom" control. The process is slightly advanced and a bit too much to go into on this forum. There's a couple of books that walk you through this process, one is the Visual C++ Bible and the other is Programming Microsoft Visual C++ (from Microsoft press).
Controls such as Tree Views and List Views should give you mouse down events. Also things like CButton do it by default.:)
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top