Solved

size

Posted on 1998-10-30
3
159 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now