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. Subclassing problem: WM_LBUTTONDOWN is missing

Subclassing problem: WM_LBUTTONDOWN is missing

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
12 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.
  • S sps itsec46

    Hi, the "& ~" construction means to remove the class style CS_DBLCLKS from the window. But this isn't necessarily the source of your problem. MSDN says the following:

    >> If a window does not have the CS_DBLCLKS style, Windows sends
    the following message sequence to the window: WM_LBUTTONDOWN,
    WM_LBUTTONUP, WM_LBUTTONDOWN, and WM_LBUTTONUP.

    >> If a window does have the CS_DBLCLKS style, Windows sends the
    following message sequence: WM_LBUTTONDOWN, WM_LBUTTONUP,
    WM_LBUTTONDBLCLK, and WM_LBUTTONUP. That is, the second
    WM_LBUTTONDOWN message is replaced by a WM_LBUTTONDBLCLK
    message.

    So I guess the problem is located somewhere else. regards, mykel If they give you lined paper, write the other way!

    A Offline
    A Offline
    Axonn Echysttas
    wrote on last edited by
    #3

    Yeah, I read the MSDN too... pretty friggin strange. Thanks for the explanation about & ~. -= E C H Y S T T A S =- The Greater Mind Balance

    1 Reply Last reply
    0
    • A Axonn Echysttas

      Hm... I got a weird weird problem. I subclassed the Systray Clock window but the WM_LBUTTONDOWN message ain't comming through my window procedure, the one I subclassed it to. This is really something 'cause subclassing is meant to direct ALL messages to me, but that message simply ... doesn't get here. What could be wrong?? I receive other messages as WM_PAINT and the subclassing is perfect since I already use it for other purposes. Could this be a hint? SetClassLong(pcwps->hwnd, GCL_STYLE, GetClassLong(hwndSystrayClockWindow, GCL_STYLE) & ~CS_DBLCLKS) What does "& ~" do anyway? I haven't been programming in C++ for such a long time and I am unfamiliar with that construction. Is it meant to subtract an attribute from that window's Class Bits? Pffff... weird stuff goin' on here... ::- |. -= E C H Y S T T A S =- The Greater Mind Balance

      A Offline
      A Offline
      Axonn Echysttas
      wrote on last edited by
      #4

      Beah this sucks and it's stupid. I can't beleive it. I just don't get those messages. Beah. I'm gonna put myself a hook there and story over. Nobody messes with hooks anyway, they rule. I don't like loading the system but a tiny HH_MOUSE on explorer.exe won't kill anybody :- D. It's 3:18 AM and nobody answers... so I'll just do it like this since in about 12 hours I gotta release this stuff I'm working at. I'll check this topic after that... maybe some wise guy here has a clue why those stupid messages don't get in the WndProc that I made for the Systray Clock. -= E C H Y S T T A S =- The Greater Mind Balance

      1 Reply Last reply
      0
      • A Axonn Echysttas

        Hm... I got a weird weird problem. I subclassed the Systray Clock window but the WM_LBUTTONDOWN message ain't comming through my window procedure, the one I subclassed it to. This is really something 'cause subclassing is meant to direct ALL messages to me, but that message simply ... doesn't get here. What could be wrong?? I receive other messages as WM_PAINT and the subclassing is perfect since I already use it for other purposes. Could this be a hint? SetClassLong(pcwps->hwnd, GCL_STYLE, GetClassLong(hwndSystrayClockWindow, GCL_STYLE) & ~CS_DBLCLKS) What does "& ~" do anyway? I haven't been programming in C++ for such a long time and I am unfamiliar with that construction. Is it meant to subtract an attribute from that window's Class Bits? Pffff... weird stuff goin' on here... ::- |. -= E C H Y S T T A S =- The Greater Mind Balance

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #5

        When the WM_NCHITTEST message (which always precedes the other mouse messages) is sent to the clock window, it returns the value HTTRANSPARENT, causing Windows to send the message to its parent, a window of class "TrayNotifyWnd". This also returns HTTRANSPARENT, so the message is sent to its parent, a window of class "Shell_TrayWnd". This window returns HTBORDER, indicating a click in the non-client area, so Windows then sends a WM_NCLBUTTONDOWN to the Shell_TrayWnd window - the child windows are treated as being transparent and do not receive the mouse click messages. The Shell_TrayWnd window is the one that actually receives and processes the mouse click messages.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        A 1 Reply Last reply
        0
        • R Ryan Binns

          When the WM_NCHITTEST message (which always precedes the other mouse messages) is sent to the clock window, it returns the value HTTRANSPARENT, causing Windows to send the message to its parent, a window of class "TrayNotifyWnd". This also returns HTTRANSPARENT, so the message is sent to its parent, a window of class "Shell_TrayWnd". This window returns HTBORDER, indicating a click in the non-client area, so Windows then sends a WM_NCLBUTTONDOWN to the Shell_TrayWnd window - the child windows are treated as being transparent and do not receive the mouse click messages. The Shell_TrayWnd window is the one that actually receives and processes the mouse click messages.

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          A Offline
          A Offline
          Axonn Echysttas
          wrote on last edited by
          #6

          Hi Ryan : ). Actually, I got that one subclassed too and I don't get nothing there either, beleive it or not. I solved my stuff with a mouse hook over explorer.exe but this isn't a solution I would accept if I would have alternatives. Unfortunately, I don't. Is it possible to make the TrayClockWClass accept mouse events?? Possibly chaning its class style ???? I don't know... -= E C H Y S T T A S =- The Greater Mind Balance

          R 1 Reply Last reply
          0
          • A Axonn Echysttas

            Hi Ryan : ). Actually, I got that one subclassed too and I don't get nothing there either, beleive it or not. I solved my stuff with a mouse hook over explorer.exe but this isn't a solution I would accept if I would have alternatives. Unfortunately, I don't. Is it possible to make the TrayClockWClass accept mouse events?? Possibly chaning its class style ???? I don't know... -= E C H Y S T T A S =- The Greater Mind Balance

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #7

            Are you checking for WM_NCLBUTTONDOWN messages? You won't get WM_LBUTTONDOWN messages because the clock window is setup to be in the non-client area of the tray window. You could make the clock accept mouse events by overriding WM_NCHITTEST and return HTCLIENT from it, except then its standard functionality would not work.

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            A 1 Reply Last reply
            0
            • R Ryan Binns

              Are you checking for WM_NCLBUTTONDOWN messages? You won't get WM_LBUTTONDOWN messages because the clock window is setup to be in the non-client area of the tray window. You could make the clock accept mouse events by overriding WM_NCHITTEST and return HTCLIENT from it, except then its standard functionality would not work.

              Ryan

              "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

              A Offline
              A Offline
              Axonn Echysttas
              wrote on last edited by
              #8

              I ain't getting no messages. Here's my check: LRESULT CALLBACK WndProcTaskBar (HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (wParam) //Depending on the messsage. { case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: .......... TaskBar being, of course, Shell_TrayWnd. Oh well, I guess I can play around with WM_NCHITTEST... thanks for the help once again, this ain't the first time you helped me :- ). -= E C H Y S T T A S =- The Greater Mind Balance

              R 1 Reply Last reply
              0
              • A Axonn Echysttas

                I ain't getting no messages. Here's my check: LRESULT CALLBACK WndProcTaskBar (HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (wParam) //Depending on the messsage. { case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: .......... TaskBar being, of course, Shell_TrayWnd. Oh well, I guess I can play around with WM_NCHITTEST... thanks for the help once again, this ain't the first time you helped me :- ). -= E C H Y S T T A S =- The Greater Mind Balance

                R Offline
                R Offline
                Ryan Binns
                wrote on last edited by
                #9

                Just out of interest, what's your default case doing? Is it calling DefWindowProc() or CallWindowProc() with the previous (unsubclassed) window procedure? It should be doing the latter if you want to retain functionality.

                Ryan

                "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                -- modified at 4:21 Wednesday 25th January, 2006

                A 1 Reply Last reply
                0
                • R Ryan Binns

                  Just out of interest, what's your default case doing? Is it calling DefWindowProc() or CallWindowProc() with the previous (unsubclassed) window procedure? It should be doing the latter if you want to retain functionality.

                  Ryan

                  "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                  -- modified at 4:21 Wednesday 25th January, 2006

                  A Offline
                  A Offline
                  Axonn Echysttas
                  wrote on last edited by
                  #10

                  All my cases (Systray Clock, TaskBar, Systray Window) are CallWindowProc with the handle returned when I subclassed via SetWindowLong.... Hm, as far as I see the hook isn't even as good as I thought. It has a few minor problems. But if I have no choice I'll keep it. I think I will soon try that HTCLIENT thingy that you mentioned. But right now I can't 'cause I gotta release on my head and just a few more hours to deliver it. (it's the second Beta of the freeware application I'm working on and I'm giving it to some more friends to use and report bugs ::- D ). -= E C H Y S T T A S =- The Greater Mind Balance -- modified at 6:19 Wednesday 25th January, 2006

                  R 1 Reply Last reply
                  0
                  • A Axonn Echysttas

                    All my cases (Systray Clock, TaskBar, Systray Window) are CallWindowProc with the handle returned when I subclassed via SetWindowLong.... Hm, as far as I see the hook isn't even as good as I thought. It has a few minor problems. But if I have no choice I'll keep it. I think I will soon try that HTCLIENT thingy that you mentioned. But right now I can't 'cause I gotta release on my head and just a few more hours to deliver it. (it's the second Beta of the freeware application I'm working on and I'm giving it to some more friends to use and report bugs ::- D ). -= E C H Y S T T A S =- The Greater Mind Balance -- modified at 6:19 Wednesday 25th January, 2006

                    R Offline
                    R Offline
                    Ryan Binns
                    wrote on last edited by
                    #11

                    Someone who knows how to subclass properly :cool:

                    Ryan

                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                    A 1 Reply Last reply
                    0
                    • R Ryan Binns

                      Someone who knows how to subclass properly :cool:

                      Ryan

                      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                      A Offline
                      A Offline
                      Axonn Echysttas
                      wrote on last edited by
                      #12

                      Yeah, not that it would help me much apparently ::- S. -= E C H Y S T T A S =- The Greater Mind Balance

                      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