Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OnRButtonUp

OnRButtonUp

Scheduled Pinned Locked Moved C / C++ / MFC
htmldatabasecomtutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    greba
    wrote on last edited by
    #1

    I would like to be able to capture a right click on a button. CButton doesn't seem to allow me do so, it only has click and double click messages. I tried creating my own button which was derived from CButton. The header file definition: class CMyButton : public CButton { public: afx_msg void OnRButtonUp(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() }; And then in my implementation file I have: BEGIN_MESSAGE_MAP(CMyButton, CButton) ON_WM_RBUTTONUP() END_MESSAGE_MAP() void CMyButton::OnRButtonUp(UINT nFlags, CPoint point) { //Stuff I want to do. } With this, I capture all right clicks on the dialog, not exactly what I wanted. Is there a way for a button to capture right clicks? I would also like to capture left clicks, but that should be simple once I know how to capure right clicks. Greba, My lack of content on my home page should be entertaining.

    G G 2 Replies Last reply
    0
    • G greba

      I would like to be able to capture a right click on a button. CButton doesn't seem to allow me do so, it only has click and double click messages. I tried creating my own button which was derived from CButton. The header file definition: class CMyButton : public CButton { public: afx_msg void OnRButtonUp(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() }; And then in my implementation file I have: BEGIN_MESSAGE_MAP(CMyButton, CButton) ON_WM_RBUTTONUP() END_MESSAGE_MAP() void CMyButton::OnRButtonUp(UINT nFlags, CPoint point) { //Stuff I want to do. } With this, I capture all right clicks on the dialog, not exactly what I wanted. Is there a way for a button to capture right clicks? I would also like to capture left clicks, but that should be simple once I know how to capure right clicks. Greba, My lack of content on my home page should be entertaining.

      G Offline
      G Offline
      greba
      wrote on last edited by
      #2

      Now that I've answered my own question :) All I needed to do (it seems) was to add Default() in the OnRButtonUp(...) function. Like this: BEGIN_MESSAGE_MAP(CMyButton, CButton) ON_WM_RBUTTONUP() END_MESSAGE_MAP() void CMyButton::OnRButtonUp(UINT nFlags, CPoint point) { Default(); } Greba, My lack of content on my home page should be entertaining.

      1 Reply Last reply
      0
      • G greba

        I would like to be able to capture a right click on a button. CButton doesn't seem to allow me do so, it only has click and double click messages. I tried creating my own button which was derived from CButton. The header file definition: class CMyButton : public CButton { public: afx_msg void OnRButtonUp(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() }; And then in my implementation file I have: BEGIN_MESSAGE_MAP(CMyButton, CButton) ON_WM_RBUTTONUP() END_MESSAGE_MAP() void CMyButton::OnRButtonUp(UINT nFlags, CPoint point) { //Stuff I want to do. } With this, I capture all right clicks on the dialog, not exactly what I wanted. Is there a way for a button to capture right clicks? I would also like to capture left clicks, but that should be simple once I know how to capure right clicks. Greba, My lack of content on my home page should be entertaining.

        G Offline
        G Offline
        G Steudtel
        wrote on last edited by
        #3

        Hi, The problem is, prior of catching the button up message the button DOWN message must be handled!. What you do, is catching all down messages, because when the mouse button is released your button provides the only handler for UP messages. I know it's weird. But best is to react on the down message, setting a flag and in the UP handler do any action only if the flag is set. And always rest the flag. GSte

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups