Solved

Help with Form.Resize event (C#)

Posted on 2008-10-25
4
2,424 Views
Last Modified: 2013-12-17
I have a dilema I cannot seem to solve. I am trying to keep a form resizable, but I want to force it to keep a size ratio of 4:3 no matter how big or small the form gets. I am ok with creating the event I am just not sure the logic behind doing this. I have not found a good way to disable form resizing. I know I can change the FormBorderStyle so that the resizing becomes disabled, however each one of those options makes the form look slightly different by adjusting the size of the forms border, etc (at least in vista). So this makes the form look very clunky when resizing. If someone could provide me with a solution in example form I would appreciate it.
0
Comment
Question by:Pretzel_Jesus
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
Comment Utility
not a direct solution but i found a sample code how this can be done
please read teh following link
http://bytes.com/forum/thread231885.html
0
 
LVL 18

Expert Comment

by:Priest04
Comment Utility
A simple way to disable form resising without changing form appearance is to set Form's MaximiumSize and MinimumSize property to the same value (desired size).


As for hte 4:3 aspect ratio a simple

private void Form1_Resize(object sender, EventArgs e)
{
    this.Width = this.Height * (4 / 3);
}

will work, but will cause some flickering. If you don't like the flickering the only other way (AFAIK) is to subclass WM_SIZE message.

Goran
0
 

Author Comment

by:Pretzel_Jesus
Comment Utility
Your code is much simpler than mine, but I accomplished basically the same thing:

if (videoForm.Size.Height >= Convert.ToInt32(videoForm.Size.Width * .75))
            {
                videoForm.Height = Convert.ToInt32(videoForm.Width * .75);
            }
            else if (videoForm.Size.Width >= Convert.ToInt32(videoForm.Size.Height / .75))
            {
                videoForm.Height = Convert.ToInt32(videoForm.Width * .75);
            }

My problem is exactly what you said... massive flicking and it looks like shit. Since I am fairly new to C# I really have no idea how to "subclass WM_SIZE message.". Can you give me an example of how I could accomplish this?
0
 
LVL 18

Expert Comment

by:Priest04
Comment Utility
Follow the link ragi posted, there you have explanation how to implement subclassing of WM_SIZING. If you dont succeed in implementing it, post here and I (or someone else) will explain.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

762 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

8 Experts available now in Live!

Get 1:1 Help Now