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. OnLButtonDown cannot catch mouse click on CButton

OnLButtonDown cannot catch mouse click on CButton

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
3 Posts 3 Posters 0 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.
  • C Offline
    C Offline
    caykahve
    wrote on last edited by
    #1

    Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance

    G M 2 Replies Last reply
    0
    • C caykahve

      Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      The standard Windows button issues the BN_CLICKED notification (which you handle via an OnBnClicked... function) when the button is released, not when it is pressed. If you want to perform an action when the button is pressed, you will need to create your own button class and handle the WM_LBUTTONDOWN message.


      Software Zen: delete this;

      1 Reply Last reply
      0
      • C caykahve

        Hi, I use OnLButtonDown and OnLButtonUp because I want to control the left mouse button press and release over more than one button at the same time. However, if I click on the empty area of the dialog I get these functions called, while I cannot get them called when I click on the buttons themselves. :doh: There is no OnBnClickedButton..() function called. Do I have to change the properties of the buttons? Thanks in advance

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        The mouse message is going to the window that the cursor is over, since that's the window being acted on. So when you click the button, the button gets the message, not the button's parent. You'll need to subclass the button and handle WM_LBUTTONDOWN in your subclass. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.

        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