Add Event Handler

  • Thread starter Thread starter Jacky Luk
  • Start date Start date
J

Jacky Luk

I want to include some code for the MouseDown Event. I would like to add
this for the formview or a picturebox, how come there are no messages for me
to choose from. Even I created a button, no messages are shown in the pick
dialog box....any help is appreicated
Thanks
jack
 
Jacky Luk said:
I want to include some code for the MouseDown Event. I would like to add
this for the formview or a picturebox, how come there are no messages for
me to choose from. Even I created a button, no messages are shown in the
pick dialog box....any help is appreicated
Thanks
jack
Let's start with the template you're using. What type of C++ project are we
talking about?
 
For ANY object 'control' which is derived from Control* the following will
add a mouse down handler for it:

control->MouseDown += new MouseEventHandler( handler_namespace_pointer,
handler_name ) ;

and the handler must be of the form:

void handler_name( Object* control, MouseEventArgs e ) ;

Other event handlers are done similarly. It is good practive to also remove
these handlers when deconstructing (although in a gc environment this is not
necessary), and be aware you can add the same handler more than once if not
careful...

Hope this helps...

[==Peteroid==]
 
you have go to your form design, you display control's proprieties,
and you click on icon "events"(yellow icon) in the proprieties panel,
there are all events for the selected control, you doube click on the
event you want to add and code will be added automatically

tel me if you do it
 
Hi I'm using MFC. As I was rendering in the formview,
I found there were no corresponding event handlers for Mouseclick.(Even
nothing else), do i have to adjust the settings? Basically all new objects I
put on the form have no event handlers to add. They were all empty for the
yellow icon...
Thanks
Jack
 
Jacky Luk said:
Hi I'm using MFC. As I was rendering in the formview,
I found there were no corresponding event handlers for Mouseclick.(Even
nothing else), do i have to adjust the settings? Basically all new objects
I put on the form have no event handlers to add. They were all empty for
the yellow icon...
Thanks
Jack
As you are asking about event handlers in MFC and nobody here appears to
have anything else to add, may I suggest that you post your question in:

microsoft.public.mfc

I believe you'll find answers there.
 
Back
Top