Solved

Resize controls and screen resolution independence without 3rd party controls....

Posted on 2007-04-04
10
319 Views
Last Modified: 2013-11-26
I am looking for some help in figuring out the best way to resize our applications. Right now we use a 3rd party resize tool and would like to get away from it if possible.  After talking to Microsoft the other day about a unrelated problem he said that if was are using VS2005 that we dont need a 3rd party resize tool.  I'm attaching a little sample project with one form.  If you open it at 1024x768 and run the app you will notice that everything on the form shows up fine.  If you then drop your resolution down to 800x600 you will notice that it only shows about half of the form because the form didnt resize nor did the controls on the form resize.  Can someone show me in basic.net how to resize the form using docking and anchoring and autoscaling(all suggested by Microsoft) so that all the controls appear on the form just like they do in 1024 res.
0
Comment
Question by:pmac38CDS
  • 5
  • 5
10 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18851222
Hi pmac38CDS;

This is what Microsoft was talking about in this article. Talks about original support, VS 2002 & VS 2003 and current support VS 2005.  You also did not post a link to the project.

    http://msdn2.microsoft.com/en-us/library/ms229605.aspx

Fernando
0
 
LVL 1

Author Comment

by:pmac38CDS
ID: 18851264
I am trying to post the link now.  I always forget where it is that I have to go to upload a sample.
0
 
LVL 1

Author Comment

by:pmac38CDS
ID: 18851269
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18851306
Hi pmac38CDS;

This is the EE-Stuff web site to post uploads. Username and password is the same as the main EE web site.

http://www.ee-stuff.com/login.php

Fernando
0
 
LVL 1

Author Comment

by:pmac38CDS
ID: 18851556
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18853739
Hi pmac38CDS;

I have not been able to make it work correctly. The following will cause you a problem. The form height is set to 721 pixels and the form can not be made bigger then the resolution of the screen. At 1024 x 768 it has a little space on the top and bottom of the form but when set to 800 x 600 the system automatically sets the height of the form at 600 pixels and does not display the bottom row of buttons. Even if you did something like the following in form load:

        If Screen.PrimaryScreen.Bounds.Width < 1024 Then
            Me.Scale(New SizeF(0.95F, 0.95F))
        End If

The form has already been resized before it gets to the form load and therefore shows a scaled down version with still no buttons on the bottom in view. The only way I have been able to get the whole form to be viewable is by doing the following:

        If Screen.PrimaryScreen.Bounds.Width < 1024 Then
            Me.AutoScroll = True
        End If

Which places scroll bars as needed and allowing you to scroll the row of buttons to come into view, This will take the whole screen. To make the form have some space around it at that resolution you can do the following in the form load.

        If Screen.PrimaryScreen.Bounds.Width < 1024 Then
            Me.AutoScroll = True
            Me.Scale(New SizeF(0.95F, 0.95F))
        End If

The Me.Scale will scale down the whole form to 95% of the original size when ran in a resolution lower then 1024 x 768.

Fernando
0
 
LVL 1

Author Comment

by:pmac38CDS
ID: 18858961
So none of the code resizes each control?  Not only do we want the form itself to look the same we also want each control to be resized to fit that resolution.  I played around with some of your code and no matter which resolution I was at, the buttons for instance seemed to stay the same size and never adjusted to which resolution it was in.  Right now we use Larcom and Youngs 3rd party resizer.  What we do is just add it to each form and then it resizes every control on that form to fit whatever resolution the client using our app is at.  The Microsoft guy said this could be accomplished also.  Is that right or am I missing something?
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 18860326
The following is from the Microsoft article:

An analogous situation occurs when an application is designed for a certain display resolution. The most common display resolution is 96 dots per inch (DPI), but higher resolution displays supporting 120, 133, 170, and above are becoming more common. Without adjustment, an application, especially a graphics-based one, designed for one resolution will appear either too large or too small when run at another resolution.

Automatic scaling seeks to ameliorate these problems by automatically resizing the form and its child controls according to the relative font size or display resolution. The Windows operating system supports automatic scaling of dialog boxes using a relative unit of measurement called dialog units. A dialog unit is based on the system font and its relationship to pixels can be determined though the Win32 SDK function GetDialogBaseUnits. When a user changes the theme used by Windows, all dialog boxes are automatically adjusted accordingly.

The above is talking about DPI as the resolution. Which means that a monitor set to 1024 x 768 with a DPI of 96 will display the same, without scaling, on a monitor of resolution 800 x 600 at a DPI of 96. What I believe would be the case is that if the program was developed on a system with a screen resolution of 1024 x 768 at a DPI setting of 133 and that program was run on a system with a screen resolution of 800 x 600 with a DPI setting of 96 then the form and all of its child control would scale. Which is not what you are looking for.

Fernando
0
 
LVL 1

Author Comment

by:pmac38CDS
ID: 18863617
So you are saying bascially that I have to stick with my 3rd party resizer to handle this for me?
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 250 total points
ID: 18864238
In my opinion yes. They will scale if the two systems are of different DPI capabilities but not when the system was developed under 1 resolution such as 1024 x 768 and ran on another resolution such as 800 x 600.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now