G
Graham McKechnie
Hi all,
A couple of days ago I started a thread "Resolution differences between
VS2003 and VS2005". I didn't get too many bites, but the following maybe of
interest.
It would appear the resolution changes required for all controls that are on
a existing form or are placed on a new form are automatically handled. Forms
designed in the designer have the following code automatically added in the
Formxx.Designer.cs part of the form.
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
This is the new mechanism that is used to kick off automatic scaling. See
article in help "Automatic Scaling in Windows Forms". So for standard
controls added via the IDE this will be enough (I haven't as yet tested
adding one of my custom controls through the IDE)
However if you are adding your own custom controls dynamically in code, you
will have have to control scaling of those controls. I've added the
following code to a couple of my controls and have now overcome my immediate
problem. The following is an example constructor.
public GPSMarkerBar(Form parent)
{
this.Size = new Size(204,107);
gpsMarkerCollection = new GPSMarkerCollection();
this.grayPen = new Pen(Color.SlateGray);
this.steelBlueBrush = new SolidBrush( Color.SteelBlue );
this.lightSteelBlueBrush = new SolidBrush( Color.LightSteelBlue);
this.whiteBrush = new SolidBrush(Color.White);
this.isInstantiated = true;
// new code for VS 2005
if (parent.AutoScaleDimensions.Width == 192f)
{
this.ScaleControl(new SizeF(2f, 2f), BoundsSpecified.All);
}
}
It's a bit crude as its only handling the resolution change, but it doing
the job for the moment
HTH
Graham
A couple of days ago I started a thread "Resolution differences between
VS2003 and VS2005". I didn't get too many bites, but the following maybe of
interest.
It would appear the resolution changes required for all controls that are on
a existing form or are placed on a new form are automatically handled. Forms
designed in the designer have the following code automatically added in the
Formxx.Designer.cs part of the form.
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
This is the new mechanism that is used to kick off automatic scaling. See
article in help "Automatic Scaling in Windows Forms". So for standard
controls added via the IDE this will be enough (I haven't as yet tested
adding one of my custom controls through the IDE)
However if you are adding your own custom controls dynamically in code, you
will have have to control scaling of those controls. I've added the
following code to a couple of my controls and have now overcome my immediate
problem. The following is an example constructor.
public GPSMarkerBar(Form parent)
{
this.Size = new Size(204,107);
gpsMarkerCollection = new GPSMarkerCollection();
this.grayPen = new Pen(Color.SlateGray);
this.steelBlueBrush = new SolidBrush( Color.SteelBlue );
this.lightSteelBlueBrush = new SolidBrush( Color.LightSteelBlue);
this.whiteBrush = new SolidBrush(Color.White);
this.isInstantiated = true;
// new code for VS 2005
if (parent.AutoScaleDimensions.Width == 192f)
{
this.ScaleControl(new SizeF(2f, 2f), BoundsSpecified.All);
}
}
It's a bit crude as its only handling the resolution change, but it doing
the job for the moment
HTH
Graham