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

R

Rich

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
 
M

Michel Posseth [MCP]

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
 
K

kimiraikkonen

Hi,
First you can look at this documentation on MSDN:
http://msdn.microsoft.com/en-us/library/ms229605(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 :)
 
M

Michel Posseth [MCP]

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
 
R

Rich

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.
 
C

Cor Ligthert[MVP]

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
 
K

kimiraikkonen

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
 
R

rowe_newsgroups

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/
 
R

Rich

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?
 
T

Tom Shelton

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
 
J

James Hahn

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top