Computing.Net > Forums > Programming > How to Resize Windows - C++ MFC

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to Resize Windows - C++ MFC

Reply to Message Icon

Name: TENDROUSBEASTIE
Date: February 4, 2004 at 13:40:53 Pacific
OS: Windows XP Pro
CPU/Ram: Athlon 1.2ghz / 768Mb pc1
Comment:

Hello Compadres,

I'm trying to teach myself C++, using the MFC class libraries, and am, on the whole doing quite well. I am by no means good at it though, so please try and be simple with any advice.

I have an ongoing program I'm writing to help learn it, a program based on the standard SDI MFC generated by the AppWizard in MS Virtual Studio 6. My question is this:

How can I control the way the main (and only) window is resized by the user. Specifically, I want to be able to have it so that the windows will only resize diagonally (so that if the user tries to resize it vertically the prgram forces it to resize an equall ammount horizontally, and vice versa).
I would also like to be able to have a minimum and maximum size that the window can be resized to.

Are either of these things possible, and if so are they within the scope of a beginner such as myself?

Thanks for any advice.


Bye.



Sponsored Link
Ads by Google

Response Number 1
Name: Daemon Rose
Date: February 5, 2004 at 09:18:04 Pacific
Reply:

Hey, here's an example of how to force a min size requirement. Max is the same code (just replace the x and y values with there maximums and change '<' to '>'). The only difference is forcing diagonal resizing, in which case you will need to keep track of the old X and Y values to know which axis is changing, and simply set the x and y equal to each other.

Here's min:

in your OnSize() method start with:

if (cx<630 || cy<370) {
if (cx <630)
cx=630;
if (cy<370)
cy=370;
this->SetWindowPos(NULL, 0, 0, cx, cy, 0);
CDialog::OnSize(nType, cx, cy);
}


0
Reply to Message Icon

Related Posts

See More


java problem Turbo Pascal DOS/WNIDOWS....



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to Resize Windows - C++ MFC

how to run my C++ program in bakgrn www.computing.net/answers/programming/how-to-run-my-c-program-in-bakgrn/12618.html

how to programm in C++ (for null le www.computing.net/answers/programming/how-to-programm-in-c-for-null-le/12576.html

how to manipulated windows command www.computing.net/answers/programming/how-to-manipulated-windows-command/14736.html