Solved

size

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

744 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

10 Experts available now in Live!

Get 1:1 Help Now