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. Button message - half clicked?

Button message - half clicked?

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncementlearning
3 Posts 2 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.
  • M Offline
    M Offline
    Moak
    wrote on last edited by
    #1

    Hi, is there a message when a button is clicked "half"? I mean when you click a button, but release mouse button while not being over the button. As a result the button has the focus, but of course a ON_BN_CLICKED is not send. Can I handle this case? I want to give the focus back to the previous control. Do I need to catch mouse messages or is there a button message I can handle? Thx, Moak

    J 1 Reply Last reply
    0
    • M Moak

      Hi, is there a message when a button is clicked "half"? I mean when you click a button, but release mouse button while not being over the button. As a result the button has the focus, but of course a ON_BN_CLICKED is not send. Can I handle this case? I want to give the focus back to the previous control. Do I need to catch mouse messages or is there a button message I can handle? Thx, Moak

      J Offline
      J Offline
      JennyP
      wrote on last edited by
      #2

      I have used the WM_LBUTTONDOWN in this case and then compared the mouse position with the button's rectangle (easily obtained from CButtonCtrl) to see if the user clicked in the button you want. There may be an easier way, but that's one method. JennyP

      M 1 Reply Last reply
      0
      • J JennyP

        I have used the WM_LBUTTONDOWN in this case and then compared the mouse position with the button's rectangle (easily obtained from CButtonCtrl) to see if the user clicked in the button you want. There may be an easier way, but that's one method. JennyP

        M Offline
        M Offline
        Moak
        wrote on last edited by
        #3

        or as alternatives... if I don't get a message from the button: 2) How about handling WM_LBUTTONUP once and check GetFocus(). Code must be added to PreTranslateMessage() handler of dialog/view. 3) Send a notify from the button to the parent, if button is released but not full clicked. Requires a class derived from CButton, also dialog/view has to handle WM_NOTIFY. 4) Creating a button that can NOT gain focus... like a toolbar button. I think this approach sounds best (and reuseable), anyone with some comments?

        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