Window title bar - detecting drag end
-
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 theCMyDialog::OnNcLButtonDown()
function but it does not work. -
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 theCMyDialog::OnNcLButtonDown()
function but it does not work. -
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 theCMyDialog::OnNcLButtonDown()
function but it does not work.try overloading
WM_NCHITTEST
message, the code will look something like thisUINT 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; }
wherembLButtonDown
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 -
try overloading
WM_NCHITTEST
message, the code will look something like thisUINT 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; }
wherembLButtonDown
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, /yawarI said "try overloading".. that was not right, I meant "try writing message handler for"... :):):):)
-
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 theCMyDialog::OnNcLButtonDown()
function but it does not work.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 callingGetCursorPos()
and checking if the point lies within the caption bar.GetWindowRect()
andGetSystemMetrics()
can help you in your computation. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com