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. WM_LBUTTONDOWN wanted

WM_LBUTTONDOWN wanted

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
10 Posts 4 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.
  • A Offline
    A Offline
    Alexander M
    wrote on last edited by
    #1

    Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)

    B T 3 Replies Last reply
    0
    • A Alexander M

      Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      Maybe the WM_LBUTTONDOWD got reflected to the parent of the control?

      T 1 Reply Last reply
      0
      • A Alexander M

        Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)

        T Offline
        T Offline
        Tom Archer
        wrote on last edited by
        #3

        If you're looking for clicks on the list control, you need to be handling LVN and NM messages such as NM_CLICK

        1 Reply Last reply
        0
        • B Blake Miller

          Maybe the WM_LBUTTONDOWD got reflected to the parent of the control?

          T Offline
          T Offline
          Tom Archer
          wrote on last edited by
          #4

          Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?

          D B 2 Replies Last reply
          0
          • A Alexander M

            Hi everyone, I have a problem concerning the WM_LBUTTONDOWN message. I'm subclassing a list view control using MFC to implement owner-draw abilities, and I'm using ON_WM_LBUTTONDOWN() in the message map. BUT: When releasing the left button on the list view control nothing happens, the message handler only gets called when double-clicking the left mouse button...? Any suggestions? Alex Don't try it, just do it! ;-)

            T Offline
            T Offline
            Tom Archer
            wrote on last edited by
            #5

            I just tried this - handling the NM_CLICK message - at both the dialog and control level and it works in both cases.

            A 1 Reply Last reply
            0
            • T Tom Archer

              Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Yes, that is the definition of reflection.


              "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

              1 Reply Last reply
              0
              • T Tom Archer

                Doesn't reflection work the other way 'round? In other words, by default messages go to the control's owner and then reflection reflects them back to the control so that message handling can be done in derived control classes?

                B Offline
                B Offline
                Blake Miller
                wrote on last edited by
                #7

                Excuse me. Maybe it was HANDLED by the parent, in which case it will not be reflected back to the control. MFC handler processing code will typically stop at the first handler it finds. If you have a stub handler in your parent window you 'forgot' about, you can scratch your head a long time trying to figure out why the 'reflected' message is never received by the control.

                1 Reply Last reply
                0
                • T Tom Archer

                  I just tried this - handling the NM_CLICK message - at both the dialog and control level and it works in both cases.

                  A Offline
                  A Offline
                  Alexander M
                  wrote on last edited by
                  #8

                  Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)

                  T 2 Replies Last reply
                  0
                  • A Alexander M

                    Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)

                    T Offline
                    T Offline
                    Tom Archer
                    wrote on last edited by
                    #9

                    In that case, you should look into the LVN_BEGINDRAG message, which sounds like what you need.

                    1 Reply Last reply
                    0
                    • A Alexander M

                      Yeah, I will check NM_CLICK. I've found out why WM_LBUTTONUP can't be received by MFC... WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list-view control enters a modal message loop until either the button is released or the mouse is moved. (MSDN) The message is only received if I move the mouse before releasing the button. Thanks for all your quick answers, Alex Don't try it, just do it! ;-)

                      T Offline
                      T Offline
                      Tom Archer
                      wrote on last edited by
                      #10

                      By the way, I just looked at some old code of mine and saw that we handled WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP and LVN_BEGINDRAG. We handled all these messages to have control over changing the mouse cursor to represent what was being moved or in some cases to display a shape that indicated something that could not be dragged. Handling these messages also enabled us to change the cursor to indicate a valid "drop zone".

                      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