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. Dragging windows

Dragging windows

Scheduled Pinned Locked Moved C / C++ / MFC
comtutorialquestion
5 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
    mcsherry
    wrote on last edited by
    #1

    I've got a full screen dialog application in which i want the user to be able to drag any dialogs which pop up to any position they want on the screen but also to limit them from certain areas of the screen. I've used the following article http://www.codeproject.com/dialog/dragwindows.asp?df=100&forumid=4307&exp=0&select=1749703[^] for the dragging of the dialog (using the OnNcHitTest method). However I can't figure out how to limit where they can drag the dialog. I've though it would be a simple matter of converting the CPoint position for the mouse into screen co-ordinates and checking if it is in a forbidden region and then setting it to be outside of this region. Any suggestions? cheers, Andy

    M 1 Reply Last reply
    0
    • M mcsherry

      I've got a full screen dialog application in which i want the user to be able to drag any dialogs which pop up to any position they want on the screen but also to limit them from certain areas of the screen. I've used the following article http://www.codeproject.com/dialog/dragwindows.asp?df=100&forumid=4307&exp=0&select=1749703[^] for the dragging of the dialog (using the OnNcHitTest method). However I can't figure out how to limit where they can drag the dialog. I've though it would be a simple matter of converting the CPoint position for the mouse into screen co-ordinates and checking if it is in a forbidden region and then setting it to be outside of this region. Any suggestions? cheers, Andy

      M Offline
      M Offline
      mcsherry
      wrote on last edited by
      #2

      ok, found my first mistake, was looking at the x part of the CPoint instead of the y! :-O I think I've figured the problem, the OnNcHitTest only seems to be called when I've released the left mouse button, so during my drag it doesn't get called. Is there anyway around this?

      M 1 Reply Last reply
      0
      • M mcsherry

        ok, found my first mistake, was looking at the x part of the CPoint instead of the y! :-O I think I've figured the problem, the OnNcHitTest only seems to be called when I've released the left mouse button, so during my drag it doesn't get called. Is there anyway around this?

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        mcsherry wrote:

        the OnNcHitTest only seems to be called when I've released the left mouse button, so during my drag it doesn't get called

        That's because the system enters a modal message loop for the duration of the drag. You may want to take a look at the WM_MOVING message. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        M 1 Reply Last reply
        0
        • M Mark Salsbery

          mcsherry wrote:

          the OnNcHitTest only seems to be called when I've released the left mouse button, so during my drag it doesn't get called

          That's because the system enters a modal message loop for the duration of the drag. You may want to take a look at the WM_MOVING message. Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          M Offline
          M Offline
          mcsherry
          wrote on last edited by
          #4

          Hi thanks for your reply, I've got the solution now, all I had to do was re-read the article I linked to in my orignal post and implement the OnLButtonDown, OnLButtonUp and OnMouseMove methods instead of the other one and do my region check in the OnMouseMove method. Andy

          M 1 Reply Last reply
          0
          • M mcsherry

            Hi thanks for your reply, I've got the solution now, all I had to do was re-read the article I linked to in my orignal post and implement the OnLButtonDown, OnLButtonUp and OnMouseMove methods instead of the other one and do my region check in the OnMouseMove method. Andy

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            mcsherry wrote:

            OnLButtonDown, OnLButtonUp and OnMouseMove methods instead of the other one and do my region check in the OnMouseMove method

            Cool :)

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            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