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

resize Form/controls/fonts dynamically to fit diff screen resoluti

P: n/a
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. But some users are using 800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch a
form with the mouse and all the controls and fonts would resize to larger or
smaller size. Does .Net framework 3.5 support this kind of functionality?
Or - is it possible to change the size of a form/controls/fonts like a google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich
Oct 27 '08 #1
Share this Question
Share on Google+
10 Replies


P: n/a

Well actually , i was verry surprised when i switched company`s a few years
ago that there actually are programmers who do not care about screen
resolutions and design forms for just one standard screen size ( a few of
my current collegues ).

I however design all my programs to fit different screen resolutions, in
..Net you can do this with multiple handy controls ( table layout pannel is
one of my favorits )
but you get pretty far with just docking and anchoring your controls the
right way .

Font sizes however i do not touch as they should be system specific

regards

Michel Posseth
http://www.vbdotnetcoder.com

"Rich" <Ri**@discussions.microsoft.comschreef in bericht
news:51**********************************@microsof t.com...
>A lot of users at my workplace use different screen resolutions, and I
build
apps to use 1680 x 1050 pixels res by default. But some users are using
800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch
a
form with the mouse and all the controls and fonts would resize to larger
or
smaller size. Does .Net framework 3.5 support this kind of
functionality?
Or - is it possible to change the size of a form/controls/fonts like a
google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich

Oct 27 '08 #2

P: n/a
Hi,
First you can look at this documentation on MSDN:
http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx

However, if you want to resize your form or specific control dynamically,
you can use Screen class to determine client PC's screen resolution and
resize by defining a new Size object like that:

'eg: To resize form at runtime on computers
'that have 800x600 screen
If Screen.PrimaryScreen.Bounds.Width = 800 AndAlso
Screen.PrimaryScreen.Bounds.Height = 600 Then
Me.Size = New Size(width,height )
End If

And it's good idea to put the code in Form's load event.

And of course, it's also good to mention in readme of application that your
application is best viewed in 1060x1050 resolution :)

--
Best regards,

Onur Güzel

"Rich" wrote:
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. But some users are using 800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch a
form with the mouse and all the controls and fonts would resize to larger or
smaller size. Does .Net framework 3.5 support this kind of functionality?
Or - is it possible to change the size of a form/controls/fonts like a google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich
Oct 27 '08 #3

P: n/a
Onur

I just start my forms maximized if i want them screen filling , cause i
guess your code has a flaw on a multi monitor system
what if my primary screen is a 22" inch widescreen monitor , but the creen
i want to view the app in is a 19 inch normall monitor

Thus a system with 2 different types of monitors, in the compay i work for
this is a common scenario
another nice one My dev system has 2x 22" inch widescreen monitors but with
both a different screen resolution ( i have one in front of me with VS and
another one beside with SMS ) the primary screen has a higher resolution as
the secondary screen , however if i start an app in VS i normally drag it to
the secondary screen , so i can easier debug the app


regards

Michel

"kimiraikkonen" <ki***********@discussions.microsoft.comschreef in bericht
news:37**********************************@microsof t.com...
Hi,
First you can look at this documentation on MSDN:
http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx

However, if you want to resize your form or specific control dynamically,
you can use Screen class to determine client PC's screen resolution and
resize by defining a new Size object like that:

'eg: To resize form at runtime on computers
'that have 800x600 screen
If Screen.PrimaryScreen.Bounds.Width = 800 AndAlso
Screen.PrimaryScreen.Bounds.Height = 600 Then
Me.Size = New Size(width,height )
End If

And it's good idea to put the code in Form's load event.

And of course, it's also good to mention in readme of application that
your
application is best viewed in 1060x1050 resolution :)

--
Best regards,

Onur Gzel

"Rich" wrote:
>A lot of users at my workplace use different screen resolutions, and I
build
apps to use 1680 x 1050 pixels res by default. But some users are using
800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could
stretch a
form with the mouse and all the controls and fonts would resize to larger
or
smaller size. Does .Net framework 3.5 support this kind of
functionality?
Or - is it possible to change the size of a form/controls/fonts like a
google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich

Oct 27 '08 #4

P: n/a
Thank you all for your replies and suggestions. I guess I will have to
experiment a little bit. Right now what I do is I have to separate .exe
files (if you can believe that). One .exe is for any screen res that is not
800x600 (will still fit on the monitor - we all have the same size monitors
except for the people using 800x600 - they get someting like a 24" monitor -
it't not fair ! :). The other .exe is for the 800x600 people

So I am supporting two separate apps which perform the exact same functions
(exact same code) except one fits on 800x600. So whatever I do to one app I
have to redo the exact same thing to the other app - this is getting old real
fast (I have been doing this for the last 3 years hoping that later version
of .Net framework wouild have similar functionality as Java).

Well, I still like .Net way better than Java (not as painful) - but I guess
Java does have this one feature that would be real nice in .Net.

"Rich" wrote:
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. But some users are using 800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch a
form with the mouse and all the controls and fonts would resize to larger or
smaller size. Does .Net framework 3.5 support this kind of functionality?
Or - is it possible to change the size of a form/controls/fonts like a google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich
Oct 27 '08 #5

P: n/a
Rich,

I will never do that, I use often the anchor and the dock, that means that
everything streches nicely and by instance textboxes and things like that
become wider as somebody wish that. The user can simply set his pixel size
as he needs it.

As somebody would give me a program that streches the program size because
of the wide of my screen, I would be very disturbed.

How would you like it as your Visual Studio on a wide screen was only
showing a 3 4 part with the bottom away, because somebody has changed the
pixel size?

jmo

Cor

"Rich" <Ri**@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
>A lot of users at my workplace use different screen resolutions, and I
build
apps to use 1680 x 1050 pixels res by default. But some users are using
800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch
a
form with the mouse and all the controls and fonts would resize to larger
or
smaller size. Does .Net framework 3.5 support this kind of
functionality?
Or - is it possible to change the size of a form/controls/fonts like a
google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich
Oct 28 '08 #6

P: n/a
Hi Michel,
The sample i've posted was just about a kind of solution for a "specific"
computer which has 800x600 resolution. As you stated, of course, forcing to a
fixed resolution may look weird on second monitor, however OP did not mention
about multi-monitoring environment.

However, beyond form resizing, if the purpose is also to align UI controls
on form, it would be a good bet to use Anchor and Dock properties as well.

--
Best regards,

Onur Güzel

"Michel Posseth [MCP]" wrote:
Onur

I just start my forms maximized if i want them screen filling , cause i
guess your code has a flaw on a multi monitor system
what if my primary screen is a 22" inch widescreen monitor , but the creen
i want to view the app in is a 19 inch normall monitor

Thus a system with 2 different types of monitors, in the compay i work for
this is a common scenario
another nice one My dev system has 2x 22" inch widescreen monitors but with
both a different screen resolution ( i have one in front of me with VS and
another one beside with SMS ) the primary screen has a higher resolution as
the secondary screen , however if i start an app in VS i normally drag it to
the secondary screen , so i can easier debug the app


regards

Michel

"kimiraikkonen" <ki***********@discussions.microsoft.comschreef in bericht
news:37**********************************@microsof t.com...
Hi,
First you can look at this documentation on MSDN:
http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx

However, if you want to resize your form or specific control dynamically,
you can use Screen class to determine client PC's screen resolution and
resize by defining a new Size object like that:

'eg: To resize form at runtime on computers
'that have 800x600 screen
If Screen.PrimaryScreen.Bounds.Width = 800 AndAlso
Screen.PrimaryScreen.Bounds.Height = 600 Then
Me.Size = New Size(width,height )
End If

And it's good idea to put the code in Form's load event.

And of course, it's also good to mention in readme of application that
your
application is best viewed in 1060x1050 resolution :)

--
Best regards,

Onur Güzel

"Rich" wrote:
A lot of users at my workplace use different screen resolutions, and I
build
apps to use 1680 x 1050 pixels res by default. But some users are using
800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could
stretch a
form with the mouse and all the controls and fonts would resize to larger
or
smaller size. Does .Net framework 3.5 support this kind of
functionality?
Or - is it possible to change the size of a form/controls/fonts like a
google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich


Oct 28 '08 #7

P: n/a
On Oct 27, 3:46*pm, Rich <R...@discussions.microsoft.comwrote:
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. *But some users are using 800
x 600, and the apps are too large for their screen. *

I used to write code in Java a few years ago (2005), and you could stretch a
form with the mouse and all the controls and fonts would resize to largeror
smaller size. * Does .Net framework 3.5 support this kind of functionality? *
Or - is it possible to change the size of a form/controls/fonts like a google
map? *

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich
One of the main reasons that WPF was created was to deal with issues
of screen resolution. If you're still early in development, it might
be worth a look to see if you could better leverage the WPF features
than the standard WinForm controls.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Oct 28 '08 #8

P: n/a
I have not specifically dealt with WPF - I only know it stands for windows
presentation foundation. What kind of articles could I search for that may
have sample code which is based on WPF?

"rowe_newsgroups" wrote:
On Oct 27, 3:46 pm, Rich <R...@discussions.microsoft.comwrote:
A lot of users at my workplace use different screen resolutions, and I build
apps to use 1680 x 1050 pixels res by default. But some users are using 800
x 600, and the apps are too large for their screen.

I used to write code in Java a few years ago (2005), and you could stretch a
form with the mouse and all the controls and fonts would resize to larger or
smaller size. Does .Net framework 3.5 support this kind of functionality?
Or - is it possible to change the size of a form/controls/fonts like a google
map?

Any suggestions appreciated how I could deal with the different screen
resolutions with VB.Net (2005/2008).

Thanks,
Rich

One of the main reasons that WPF was created was to deal with issues
of screen resolution. If you're still early in development, it might
be worth a look to see if you could better leverage the WPF features
than the standard WinForm controls.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Oct 28 '08 #9

P: n/a
On 2008-10-28, Rich <Ri**@discussions.microsoft.comwrote:
I have not specifically dealt with WPF - I only know it stands for windows
presentation foundation. What kind of articles could I search for that may
have sample code which is based on WPF?
Well googling WPF would be a good start. And if you're interested in books,
well I have a couple I like and they are:

Adam Nathan - "Windows Presentation Foundation Unleashed" - ISBN 0-672-32891-7
Charles Petzold - "Applications = Code + Markup: A Guide to Microsoft Windows
Presentation Foundation" - ISBN 0-7356-1957-3

The only drawback maybe if you don't know C# at all, since both books use C#
for their code examples (though, there are very few code examples in the Adam
Nathan's book - his primarily focuses on XAML, and that is the same in VB.NET
or C#).

HTH
--
Tom Shelton
Oct 28 '08 #10

P: n/a
The C#-only examples for WPF (which is also a significant problem in MSDN)
can be handled using the on-line code conversion sites - the samples are
well within any size limits those sites impose, and the conversion is
usually very good. A bigger problem is getting to grips with XAML, which
seems to be supported _only_ by examples with very little explanation, and
limited supporting utilities.

OP can start here:
http://msdn.microsoft.com/en-us/library/ms742522.aspx

The conversion of existing projects to WPF is best managed by hosting WPF
content within a Win32 application. But OP needs to be careful - there is a
lot of material available that does not specify the Framework version it
applies to, and is now seriously out of date as a result of the big changes
in WPF that have occurred since its release.

"Tom Shelton" <to*********@comcastXXXXXXX.netwrote in message
news:OK**************@TK2MSFTNGP04.phx.gbl...
On 2008-10-28, Rich <Ri**@discussions.microsoft.comwrote:
>I have not specifically dealt with WPF - I only know it stands for
windows
presentation foundation. What kind of articles could I search for that
may
have sample code which is based on WPF?

Well googling WPF would be a good start. And if you're interested in
books,
well I have a couple I like and they are:

Adam Nathan - "Windows Presentation Foundation Unleashed" - ISBN
0-672-32891-7
Charles Petzold - "Applications = Code + Markup: A Guide to Microsoft
Windows
Presentation Foundation" - ISBN 0-7356-1957-3

The only drawback maybe if you don't know C# at all, since both books use
C#
for their code examples (though, there are very few code examples in the
Adam
Nathan's book - his primarily focuses on XAML, and that is the same in
VB.NET
or C#).

HTH
--
Tom Shelton
Oct 28 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.