Click here to Skip to main content
15,068,879 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,

I'm trying to disable the ability to drag a window around but I haven't seem to find the correct code for it.

The ones that I have found is to do check for the WM_NCHITTEST message and if it belongs to the title bar, shift it to something else. I was hoping for a more direct solution.

Thanks in advance!
Updated 13-Aug-21 18:03pm

Managed to to solved this.

Using the OnMoving function and ON_WM_MOVING message, just change the values of the function parameter of the LPRECT to the current window size.

void MyClass::OnMoving(UINT nSide, LPRECT lpRect)
	CDialog::OnMoving(nSide, lpRect);

	// TODO: Add your message handler code here and/or call default
	// Find Current location of the dialog
	CRect CurRect;

	// Set current location as the moving location
	lpRect->left = CurRect.left;
	lpRect->top =;
	lpRect->right = CurRect.right;
	lpRect->bottom = CurRect.bottom;
will this work for you WM_GETMINMAXINFO [^]
amsga 15-Apr-12 23:20pm
This one only refers to size, I still need something to prevent users from dragging the window in different positions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900