473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Resize a form by height only

Hi,

I have a windows form which can only be resize by height. At the moment,
on the Resize event I have the following code to prevent the user
changing the width of the form:

this.Width = DEFAULT_WIDTH;

Its not ideal this method, since the user can still see the window being
resized (hard to descrive the effect, but the main windows is still in
position, but a ligher stretched version appears) but after releasing
the mouse, the Window is still the default size.

Anyone have a nicer / cleaner way of achieving this?

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
3 2128
Yes, you have to subclass the window (override the WndProc procedure), trap
the WM_SIZING event and change the width value before calling the original
WndProc procedure. See:

http://msdn.microsoft.com/library/de.../wm_sizing.asp

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"Steven Blair" <st**********@btinternet.com> escribió en el mensaje
news:uw**************@TK2MSFTNGP14.phx.gbl...
Hi,

I have a windows form which can only be resize by height. At the moment,
on the Resize event I have the following code to prevent the user
changing the width of the form:

this.Width = DEFAULT_WIDTH;

Its not ideal this method, since the user can still see the window being
resized (hard to descrive the effect, but the main windows is still in
position, but a ligher stretched version appears) but after releasing
the mouse, the Window is still the default size.

Anyone have a nicer / cleaner way of achieving this?

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Steven,

And I find that elastic look so nice.

However probably will this do what you want

\\\
private void Form1_Load(object sender, System.EventArgs e)
{
this.MaximumSize=new System.Drawing.Size(500, 300);
this.MinimumSize=new System.Drawing.Size(300, 300);
}
///

I hope this helps?

Cor
Nov 16 '05 #3
Thanks for the replies.

I tried the second solution and it worked perfect :D. Yes elastic look,
thats the word I was looking for to describe it ;)

The width is the first parameter though...

Thanks again.

Regards,

Steven
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Noah Coad [C# MCP] | last post by:
I'm creating a program the must show the time (a clock) in a user control and the text must fill the user control. How do I make text dynamically resize to fill a label/panel/usercontrol? ...
3
by: Poul C | last post by:
Hello With the code below I can resize all the components on a Form when ever the Form resizes. For the time beeing it dosn't allow a component to contain another component, but with a...
0
by: Rod Billett | last post by:
The included html contains 3 divs. One primary Div, with 2 nested divs. the second nested DIV contains an empty table. Problem 1: Phantom Space. When viewed within the browser, the div 'action...
14
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why...
2
by: Peter Proost | last post by:
Hi group I have the following piece of code that should resize the bitmap in a picture box but it doesn't work as I tought it would. Can someone help me with it? thnx Peter Public Class...
2
by: DraguVaso | last post by:
Hi, I have to DataGrid's on a form, one on the top of my form, the other at the bottom, but they though each other somewhere in the middle. What I want now is that, when I resize the form, they...
6
by: Rob | last post by:
I need to create a form that will resize only the verticle size of the Form and not the width. So far I'm partial to the following code. Can someone please elaborate the ??? . . . . Const...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
1
by: Bob Alston | last post by:
I have a system where many subforms are used. Often the size of the subform had to be larger than could be displayed without scrolling. I set the height of the subform to the typical height...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.