Dragging windows
-
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
-
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
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?
-
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?
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:
-
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:
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
-
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
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: