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. Window title bar - detecting drag end

Window title bar - detecting drag end

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi, I have an over-ridden handler CMyDialog::OnNcLButtonDown() which detects if the user selects the title bar of my dialog. The user then drags the dialog and releases the mouse button. How can my program know when the mouse button has been released? I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.

    A Y RaviBeeR 3 Replies Last reply
    0
    • A Anonymous

      Hi, I have an over-ridden handler CMyDialog::OnNcLButtonDown() which detects if the user selects the title bar of my dialog. The user then drags the dialog and releases the mouse button. How can my program know when the mouse button has been released? I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Anonymous wrote: I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work. Sorry. I mean to say the CMyDialog::OnNcLButtonUp() function

      1 Reply Last reply
      0
      • A Anonymous

        Hi, I have an over-ridden handler CMyDialog::OnNcLButtonDown() which detects if the user selects the title bar of my dialog. The user then drags the dialog and releases the mouse button. How can my program know when the mouse button has been released? I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.

        Y Offline
        Y Offline
        Yawar Maajed
        wrote on last edited by
        #3

        try overloading WM_NCHITTESTmessage, the code will look something like this UINT YourClass::OnNcHitTest(CPoint point) { int ret = YourParentCwndBasedClass::OnNcHitTest(point); if (ret == HTCAPTION) { if (GetAsyncKeyState(VK_LBUTTON) < 0) { if (!mbLButtonDown) { TRACE("\nDown"); mbLButtonDown = true; } } else { if (mbLButtonDown) { TRACE("\nUp"); mbLButtonDown = false; } } } return ret; } where mbLButtonDown would be a bool member of your class and would need to be initialized as false when constructing your window. There might be some other way to do this too, this was just a quick thing that came to my mind. HTH, /yawar

        Y 1 Reply Last reply
        0
        • Y Yawar Maajed

          try overloading WM_NCHITTESTmessage, the code will look something like this UINT YourClass::OnNcHitTest(CPoint point) { int ret = YourParentCwndBasedClass::OnNcHitTest(point); if (ret == HTCAPTION) { if (GetAsyncKeyState(VK_LBUTTON) < 0) { if (!mbLButtonDown) { TRACE("\nDown"); mbLButtonDown = true; } } else { if (mbLButtonDown) { TRACE("\nUp"); mbLButtonDown = false; } } } return ret; } where mbLButtonDown would be a bool member of your class and would need to be initialized as false when constructing your window. There might be some other way to do this too, this was just a quick thing that came to my mind. HTH, /yawar

          Y Offline
          Y Offline
          Yawar Maajed
          wrote on last edited by
          #4

          I said "try overloading".. that was not right, I meant "try writing message handler for"... :):):):)

          1 Reply Last reply
          0
          • A Anonymous

            Hi, I have an over-ridden handler CMyDialog::OnNcLButtonDown() which detects if the user selects the title bar of my dialog. The user then drags the dialog and releases the mouse button. How can my program know when the mouse button has been released? I have tried over-riding the CMyDialog::OnNcLButtonDown() function but it does not work.

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Another way to detect the end of a move by dragging the caption bar is to simply handle WM_MOVE and check if the mouse is over the window's caption bar. You can do this by calling GetCursorPos() and checking if the point lies within the caption bar. GetWindowRect() and GetSystemMetrics() can help you in your computation. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            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