Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

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);
}

![]() |
java problem
|
Turbo Pascal DOS/WNIDOWS....
|

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