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
Solved

Help with Form.Resize event (C#)

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

792 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