Catching Events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SnVzdCBjbG9zZSB5b3VyIGV5ZXMgYW5kIHNlZQ==

    #1

    Catching Events

    Hello All
    I am trying to catch a right button down event for a control before the form
    sends it to this control; I tried to do that through overriding the WndProc
    But it fails!
    Is there any way to do that?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Catching Events

    Well, you are probably not looking for the correct windows message.

    What does your WndProc method look like?


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Just close your eyes and see"
    <Justcloseyoure yesandsee@discu ssions.microsof t.comwrote in message
    news:BD0AA877-6D7C-4F8B-AE48-DEA420308F9B@mi crosoft.com...
    Hello All
    I am trying to catch a right button down event for a control before the
    form
    sends it to this control; I tried to do that through overriding the
    WndProc
    But it fails!
    Is there any way to do that?

    Comment

    • =?Utf-8?B?SnVzdCBjbG9zZSB5b3VyIGV5ZXMgYW5kIHNlZQ==

      #3
      Re: Catching Events

      const int WM_RBUTTONDOWN = 0x204;
      const int WM_RBUTTONUP = 0x205;

      protected override void WndProc(ref Message m)
      {
      switch (m.Msg)
      {
      case WM_RBUTTONDOWN: MessageBox.Show ("Down");
      break;
      case WM_RBUTTONUP: MessageBox.Show ("Up");
      break;
      default: base.WndProc(re f m);
      break;
      }
      }

      Comment

      • =?Utf-8?B?SnVzdCBjbG9zZSB5b3VyIGV5ZXMgYW5kIHNlZQ==

        #4
        Re: Catching Events

        i did it using MFC , but i am still working around to make it using C#
        here is the MFC code using a message called "PreTranslateMe ssage"


        const int RBUTTONDOWN = 0x204;
        const int RBUTTONUP= 0x205;
        BOOL Cmfc01App::PreT ranslateMessage (MSG* pMsg)
        {
        switch (pMsg->message)
        {
        case RBUTTONDOWN:ret urn true;
        case RBUTTONUP:retur n true;
        default:CWinApp ::PreTranslateM essage(pMsg);
        }
        }

        Comment

        Working...