Click here to Skip to main content
Sign Up to vote bad
good
See more: MFCC++/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 - 14:55
amsga559


2 solutions

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  
will this work for you WM_GETMINMAXINFO [^]
  Permalink  
Comments
amsga - 15 Apr '12 - 23:20
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 393
1 OriginalGriff 335
2 Arun Vasu 315
3 Maciej Los 238
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 23 Apr 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid