Solved

size

Posted on 1998-10-30
3
161 Views
Last Modified: 2010-04-02
how can i prevent the user to change the size and position of a formview based windows(visual c++ MFC).
0
Comment
Question by:saidi
  • 2
3 Comments
 
LVL 3

Expert Comment

by:danny_pav
ID: 1176570
1.  You could make the border not allow sizing.
or
2.  Use WM_GETMINMAXINFO
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1176571
To elaborate on danny's explanations

>> You could make the border not allow sizing.

Specify a window style that does not have the WS_THICKFRAME style.  Note that some of the window styles are are made up of a a bunch of styles that are ORed toegether and might include this style without you realizing it.  For example, the WS_OVERLAPPEDWINDOW and WS_POPUPWINDOW styles both include the thick frame style.

This would prevent sizing, however the user could still move the window.  To prevent them from moving it you would also have to have a style that does not have the WS_CAPTION style.    That would produce a window without a title bar (caption).  However, I suspect you don't want that.

Another approach would be to handle the WM_WINDOWPOSCHANGING message.  This is sent to the window before it is moved and specifies the window's new position and size information.  You can adjust this information so that the window is "moved" to where it already is.  

The problem with this is that it would allow the user to try to move/resize the window with the mouse, but when they let go the window would not move or resize.  If that is a problem, you could get around it by intercepting the WM_NCHITTEST message.  And converting hits on the sizing edges (HTBOTTOM, HTBOTTOMLEFT, etc.) and hits on the caption (HTCAPTION) to HTBORDER.  (You might think this would be enough.  i.e handling this message is enough and you wouldn't need to handle the position changing message, but there are ways to resize/move the window that don't use the mouse.  handling the WM_WINDOWPOSCHANGiNG message insures that the user or orther programs can't move or resize the window using any means.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1176572
Do you still need help with this?

Is this a question that was "answered" on another question.  It seems familiar.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question