Solved

Help with Form.Resize event (C#)

Posted on 2008-10-25
4
2,425 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 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

24 Experts available now in Live!

Get 1:1 Help Now