Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Capturing Button Events Visual C++ .net

Hey I have a n00bie question about capturing when a user presses down the left mouse button on a simple pushbutton. But not the biult-in events like on_clicked. I created the buttons just be dragging them off the toolbar in visualstudio.net.

I set up my Eventsink_Map for the buttoned PitchUp in the dialoug .cpp file.

BEGIN_EVENTSINK_MAP(CParallelPortTestDlg, CDialog)

ON_EVENT(CParallelPortTestDlg, PitchUp, DISPID_MOUSEDOWN, MouseDownRotateUp, VTS_I2 VTS_I2 VTS_I4 VTS_I4)
END_EVENTSINK_MAP()

and the function that it will call

void CParallelPortTestDlg::MouseDownRotateUp(short Button, short shift, long x, long y)
{
EndDialog(IDOK);
// TODO: Add your message handler code here
}

I put the EndDialog(IDOK) function so that if everything works right the program will close.

and Here is the declaration in the dialoug header file

DECLARE_EVENTSINK_MAP()
void MouseDownRotateUp(short Button, short shift, long x, long y);

I was able to use this setup to capture the mouse button going down on an animated gif object but it won't work on a push button. Do I have the wrong dispatch ID maybe ??

The reason I wish to capture when the mouse button goes down is because I have to use the buttons like this: When the mouse button goes down, I'll call a function, and when it comes back up I want to call a function. I can just do that with the biult in onbnclicked() event.
There has to be a way to do this because the buttons change when you press the mouse button down by default and stay that way untill you move the mouse off the button or let the mouse button back up.

Hope I haven't confused everyone now!!!

Any help you could provide would be great.

Thanks

Comments

  • veliusvelius Member Posts: 456
    Why wouldn't you just handle the WM_LBUTTONDOWN and WM_LBUTTONUP?
    [hr]
    When it came down to it I dropped everything and ran.
    -Ramza Final Fantasy Tactics

  • ControlFre4kControlFre4k Member Posts: 3
    : Why wouldn't you just handle the WM_LBUTTONDOWN and WM_LBUTTONUP?
    : [hr]
    : When it came down to it I dropped everything and ran.
    : -Ramza Final Fantasy Tactics
    :
    :

    Hey thanks for the help with this but I'm having a problem.

    If I use the ON_WM_LBUTTONDOWN( ) event in my dialog box how will I know which button the mouse is on when the event fires since you can't pass this event any paramaters and it will fire every time the user presses the mouse button down whether the mouse is over a button or not ??

    The only event handlers listed for buttons are

    ON_BN_CLICKED( , ) afx_msg void memberFxn( );
    ON_BN_DISABLE( , ) afx_msg void memberFxn( );
    ON_BN_DOUBLECLICKED( , ) afx_msg void memberFxn( );
    ON_BN_HILITE( , ) afx_msg void memberFxn( );
    ON_BN_PAINT( , ) afx_msg void memberFxn( );
    ON_BN_UNHILITE( , ) afx_msg void memberFxn( );

    none of which capture the event of the mouse button being pressed down which is what I need to do.

    Hopefully some can clear this up for me !! :-P
  • veliusvelius Member Posts: 456
    You will need to do a Hit Test. I'll get back to you on that later unless you know what I mean.
    [hr]
    When it came down to it I dropped everything and ran.
    -Ramza Final Fantasy Tactics

  • ControlFre4kControlFre4k Member Posts: 3
    : You will need to do a Hit Test. I'll get back to you on that later unless you know what I mean.
    : [hr]
    : When it came down to it I dropped everything and ran.
    : -Ramza Final Fantasy Tactics
    :
    :


    Actually I'm don't know how to do a "hit test" and if you could help me out that would be great.
  • veliusvelius Member Posts: 456
    To be honest I've never actually used that feature. I'm still working on how to do it in MFC but if need be I'll use Win32 API calls if necessary. I'll get back to you soon.
    [hr]
    When it came down to it I dropped everything and ran.
    -Ramza Final Fantasy Tactics

Sign In or Register to comment.