473,395 Members | 1,348 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,395 software developers and data experts.

How Do I Prevent Form Resizing

Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a title
bar (aka the Text Property is set) and the MinmizeBox, ControlBox and
MaximizeBox(es) are all set to false. It's FormBorderStyle is set to "Fixed
Single". Eventually this form will have a nice background image. I need to
use this form as sort of back drop while other forms/operations appear
during application use in front of this form, so this Form is initially
displayed with the "Show" method so it's not modal. Here's the problem:
everything initally appears as expected, but the user can still double click
on the title bar of this back drop form and it still resizes. It's set to
FixedSingle, why is it still resizing and how do I prevent this? It's OK if
they can drag the title bar to move the back drop form, but resizing is
considerd a no-no for this app. What am I missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com
Nov 17 '05 #1
6 51878
John,

There are a few ways I can see going about this.

The first would be to override the OnResize method on your form. Do NOT
call the base class implementation, and that might prevent the form from
being resized.

If that doesn't work, you can set the MaximumSize and MinimumSize
properties to the same size, and that shouldn't allow a resize of any kind
to occur.

As a last resort, you can handle the WM_NCLBUTTONDBLCLK windows message
in an overridden WndProc procedure, and do nothing when you process it (this
is sent when a non-client double click occurs, like on the frame, or title
part of the window).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to
"Fixed Single". Eventually this form will have a nice background image. I
need to use this form as sort of back drop while other forms/operations
appear during application use in front of this form, so this Form is
initially displayed with the "Show" method so it's not modal. Here's the
problem: everything initally appears as expected, but the user can still
double click on the title bar of this back drop form and it still resizes.
It's set to FixedSingle, why is it still resizing and how do I prevent
this? It's OK if they can drag the title bar to move the back drop form,
but resizing is considerd a no-no for this app. What am I missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com

Nov 17 '05 #2
Nicholas,

Thanks for the fast response. I think I just figured out how to solve this.
After thinking about the MinimumSize & MaximumSize you mentioned, I
discoevered something. First of all, I foundI had the form's WindowState set
to Maxmize. Once I set that back to Normal, it started behaving like every
other form I've ever worked with. Then I put some code into it's constructor
just after the call to InitializeComponent() to make the back drop fill the
available screen, but still allow access to the taskbar... even if it's
autohidden. Here's the temp code that I put in there. Obviously, this code
can be modified to set the back drop's size & location to some other more
desirable fixed size & location.
Point NewLoc = Screen.FromControl(this).WorkingArea.Location;
//Modifiy the location so any toolbars & taskbar can be easily accessed.
NewLoc.X += 1;
NewLoc.Y += 1;
this.Location = NewLoc;

Size NewSize = Screen.FromControl(this).WorkingArea.Size;
//Modifiy the size so any toolbars & taskbar can be easily accessed.
NewSize.Height -= 1;
NewSize.Width -= 1;
this.Size = NewSize;

this.MinimumSize = this.Size;
this.MaximumSize = this.MinimumSize;
Thanks for the help.

John

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:un**************@TK2MSFTNGP09.phx.gbl...
John,

There are a few ways I can see going about this.

The first would be to override the OnResize method on your form. Do
NOT call the base class implementation, and that might prevent the form
from being resized.

If that doesn't work, you can set the MaximumSize and MinimumSize
properties to the same size, and that shouldn't allow a resize of any kind
to occur.

As a last resort, you can handle the WM_NCLBUTTONDBLCLK windows message
in an overridden WndProc procedure, and do nothing when you process it
(this is sent when a non-client double click occurs, like on the frame, or
title part of the window).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to
"Fixed Single". Eventually this form will have a nice background image. I
need to use this form as sort of back drop while other forms/operations
appear during application use in front of this form, so this Form is
initially displayed with the "Show" method so it's not modal. Here's the
problem: everything initally appears as expected, but the user can still
double click on the title bar of this back drop form and it still
resizes. It's set to FixedSingle, why is it still resizing and how do I
prevent this? It's OK if they can drag the title bar to move the back
drop form, but resizing is considerd a no-no for this app. What am I
missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com


Nov 17 '05 #3
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to
"Fixed Single". Eventually this form will have a nice background image. I
need to use this form as sort of back drop while other forms/operations
appear during application use in front of this form, so this Form is
initially displayed with the "Show" method so it's not modal. Here's the
problem: everything initally appears as expected, but the user can still
double click on the title bar of this back drop form and it still resizes.
It's set to FixedSingle, why is it still resizing and how do I prevent
this? It's OK if they can drag the title bar to move the back drop form,
but resizing is considerd a no-no for this app. What am I missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com


Just set the MaximizeBox property to false on the form - then it can't be
maximized

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Nov 17 '05 #4
Richard,

It would appear you didn't read my post completely. I already did that. Read
my previous post to learn the solution.

John

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to
"Fixed Single". Eventually this form will have a nice background image. I
need to use this form as sort of back drop while other forms/operations
appear during application use in front of this form, so this Form is
initially displayed with the "Show" method so it's not modal. Here's the
problem: everything initally appears as expected, but the user can still
double click on the title bar of this back drop form and it still
resizes. It's set to FixedSingle, why is it still resizing and how do I
prevent this? It's OK if they can drag the title bar to move the back
drop form, but resizing is considerd a no-no for this app. What am I
missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com


Just set the MaximizeBox property to false on the form - then it can't be
maximized

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Nov 17 '05 #5
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:ea**************@TK2MSFTNGP09.phx.gbl...
Richard,

It would appear you didn't read my post completely. I already did that.
Read my previous post to learn the solution.

John

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote
in message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set to
"Fixed Single". Eventually this form will have a nice background image.
I need to use this form as sort of back drop while other
forms/operations appear during application use in front of this form, so
this Form is initially displayed with the "Show" method so it's not
modal. Here's the problem: everything initally appears as expected, but
the user can still double click on the title bar of this back drop form
and it still resizes. It's set to FixedSingle, why is it still resizing
and how do I prevent this? It's OK if they can drag the title bar to
move the back drop form, but resizing is considerd a no-no for this app.
What am I missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com


Just set the MaximizeBox property to false on the form - then it can't be
maximized

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk



Sorry John,

I missed that bit but I tested the same config on my machine and it worked
as you wanted. I cannot double click on the title bar and make it resize.

I'm using version 2.0, I don;t have a 1.1 environment to hand to test
whether it was a bug in 1.1 that has been fixed in 2.0.

Can you create a vanilla winforms app and set the MaximizeBox property to
false and test?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Nov 17 '05 #6
Richard,

Thanks again for looking into this. See my post: 10/24/2005 9:51 am CDT for
my resolution of the problem. The crux of it was that the WindowState
property was set to Maximize. This causes the undesirable behavior. When I
set it to Normal, everything went back to working as expected.

John

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2***************@TK2MSFTNGP10.phx.gbl...
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:ea**************@TK2MSFTNGP09.phx.gbl...
Richard,

It would appear you didn't read my post completely. I already did that.
Read my previous post to learn the solution.

John

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote
in message news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All,

I must be missing something really obvious, so I'd appreciate someone
helping me out. I have a simple Windows form that currently only has a
title bar (aka the Text Property is set) and the MinmizeBox, ControlBox
and MaximizeBox(es) are all set to false. It's FormBorderStyle is set
to "Fixed Single". Eventually this form will have a nice background
image. I need to use this form as sort of back drop while other
forms/operations appear during application use in front of this form,
so this Form is initially displayed with the "Show" method so it's not
modal. Here's the problem: everything initally appears as expected, but
the user can still double click on the title bar of this back drop form
and it still resizes. It's set to FixedSingle, why is it still resizing
and how do I prevent this? It's OK if they can drag the title bar to
move the back drop form, but resizing is considerd a no-no for this
app. What am I missing here?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com
Just set the MaximizeBox property to false on the form - then it can't
be maximized

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk



Sorry John,

I missed that bit but I tested the same config on my machine and it worked
as you wanted. I cannot double click on the title bar and make it resize.

I'm using version 2.0, I don;t have a 1.1 environment to hand to test
whether it was a bug in 1.1 that has been fixed in 2.0.

Can you create a vanilla winforms app and set the MaximizeBox property to
false and test?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Nov 17 '05 #7

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

Similar topics

2
by: Pamela Chatterjee | last post by:
In my Web Form I have more than one Textbox for user input. If I hit enter to any Textbox its submitting the form. How can I prevent Form submission if users hit enter to the textbox? I want to...
0
by: Perry Zamek | last post by:
I am using the Getz et al approach to form resizing, and have encountered a problem, which doesn't seem to have been mentioned here: If I "squeeze" the form that I want to resize, so that the edge...
4
by: deko | last post by:
I have a pop-up form in which user-defined parameters are entered. The parameters are entered into a subform datasheet which is bound to a table. I need to check the product of two parameters to...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
8
by: Grant | last post by:
Hello, Ive got a form with 3 textboxes - one under the other. When I set the anchor to top, left, right, and bottom for each of them and resize the form at runtime, they change size in relation...
1
by: Jon Pope | last post by:
I'm maintaining an internal tool within my organization. Some of my users have resized their system font size by changing the DPI setting from 96DPI to 120DPI (by right-clicking the desktop and...
4
by: Lee | last post by:
Hi, how can this be achieved? are there any examples anywhere? thanks in advance lee
3
by: sravan_reddy001 | last post by:
i want to prevent a form from closing.. to do this i want to handle the formClosing or FormClosed events. from here i want to prevent the form from closing. New instance of same form should...
6
by: JDeats | last post by:
I have a WinForms based application written for the .NET Framework 2.0 and in this application I need to be able to be able to take some action in code when the user finishes resizing the form. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.