Solved

Help with Form.Resize event (C#)

Posted on 2008-10-25
4
2,431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22803088
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
ID: 22803404
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
ID: 22804635
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
ID: 22805265
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

690 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