By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,473 Members | 3,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,473 IT Pros & Developers. It's quick & easy.

How Do I Prevent Form Resizing

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.