Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

size

Posted on 1998-10-30
3
Medium Priority
?
172 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 150 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

916 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