Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC C++/MFC
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!
Posted 10-Apr-12 15:55pm
amsga575
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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;
	GetWindowRect(&CurRect);
 
	// Set current location as the moving location
	lpRect->left = CurRect.left;
	lpRect->top = CurRect.top;
	lpRect->right = CurRect.right;
	lpRect->bottom = CurRect.bottom;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

will this work for you WM_GETMINMAXINFO [^]
  Permalink  
Comments
amsga at 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)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 189
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 23 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100