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

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

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
10 44041

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
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
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 27 '08 #4
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kevin Myers | last post by:
Hello folks, I am an experienced developer with other languages and applications, but a neophyte when it comes to MS Access forms. Can someone please help get me with a solution for the...
0
by: Lauren Quantrell | last post by:
In terms of resources, wondering if it makes a difference in adopting one of the three options below for resizing controls on a form and controls on a subform at the same time. option a.) Put...
1
by: Jaime Stuardo | last post by:
Hi all.... I am programming in ASP.NET 2.0 and VS.NET 2005 Beta 2. I have a MasterPage that provides basic look & feel for my pages. The main form present in the master page has this...
9
by: Adam Honek | last post by:
Hi, In VB6 and earlier if the form size was expanded by the user or maximized there had to be specific code to handle controls on the form to scale with with it. In VB.net I recall in one of...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
1
by: Vanyok | last post by:
Hi everyone :) I'm a newb to C-Sharp but more I learn about it - more I like it. I need some help please. I'm trying to find out to dynamically allocate form controls. For example I want to have 5...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
2
by: ezhils | last post by:
How to resize the form controls based on the screen resolution?
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.