How to prevent the user from moving a dialog dynamically
-
Hello, I tried the below line to make my dialog start at a certain position, with certain size, and prevent the user from moving it afterwards.
SetWindowPos(&this->wndTopMost,StartXPos,StartYPos,DlgWidth,DlgHeight,SWP_NOSENDCHANGING|SWP_NOZORDER|SWP_SHOWWINDOW);
There is no problem with the start position and the size, but I can move it. Also there is some problem withCClientDC::LineTo()
function. It sometimes draws after SetWindowPos is called, and sometimes not. I also want to write a function to enable moving again. Thanks in advance... -
Hello, I tried the below line to make my dialog start at a certain position, with certain size, and prevent the user from moving it afterwards.
SetWindowPos(&this->wndTopMost,StartXPos,StartYPos,DlgWidth,DlgHeight,SWP_NOSENDCHANGING|SWP_NOZORDER|SWP_SHOWWINDOW);
There is no problem with the start position and the size, but I can move it. Also there is some problem withCClientDC::LineTo()
function. It sometimes draws after SetWindowPos is called, and sometimes not. I also want to write a function to enable moving again. Thanks in advance...I'm sure there is an article in the Dialogs section somewhere about this, but off the top of my head... Handle the WM_NCHITTEST message (OnNcHittest). If you want the normal behaviour, fall through to the standard behaviour. If you want the dialog locked, return HTCLIENT.
...
ON_WM_NCHITEST()
...UINT CMyDialog::OnNcHitTest( CPoint point )
{
if (m_bLocked)
return HTCLIENT;return CWnd::OnNcHitTest (point);
}
Tada! Iain.
-
Hello, I tried the below line to make my dialog start at a certain position, with certain size, and prevent the user from moving it afterwards.
SetWindowPos(&this->wndTopMost,StartXPos,StartYPos,DlgWidth,DlgHeight,SWP_NOSENDCHANGING|SWP_NOZORDER|SWP_SHOWWINDOW);
There is no problem with the start position and the size, but I can move it. Also there is some problem withCClientDC::LineTo()
function. It sometimes draws after SetWindowPos is called, and sometimes not. I also want to write a function to enable moving again. Thanks in advance...Override
WM_MOVING
andWM_SIZING
to control how the window can be moved (or resized) by the user. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
I'm sure there is an article in the Dialogs section somewhere about this, but off the top of my head... Handle the WM_NCHITTEST message (OnNcHittest). If you want the normal behaviour, fall through to the standard behaviour. If you want the dialog locked, return HTCLIENT.
...
ON_WM_NCHITEST()
...UINT CMyDialog::OnNcHitTest( CPoint point )
{
if (m_bLocked)
return HTCLIENT;return CWnd::OnNcHitTest (point);
}
Tada! Iain.