Re: Resolution changes with VS2005



Hi Graham,

This is true and a bit of a pain but you might find using the following code
example as this will support future higher resolution devices without code
change plus you need not "hard code" all coorinates for all controls:

const int DESIGNSIZE = 96; //The initial size was that form was designed
under.

/// <summary>

/// Helper method to draw unselected item.

/// </summary>

/// <param name="y">Y position where to start drawing the item.</param>

/// <param name="_tasklistItem">Instance of the tasklistitem object.</param>

private void DrawUnselectedItem(Graphics _grfx, int y, TaskListItem
_tasklistItem, bool paint_b)

{

if (_tasklistItem.Icon != null)

{

_grfx.DrawIcon(_tasklistItem.Icon, Convert.ToInt32(3 * _grfx.DpiY /
DESIGNSIZE), Convert.ToInt32(y + (3 * _grfx.DpiY / DESIGNSIZE)));

}

SolidBrush optionTitle_brush = new
SolidBrush(_tasklistItem.ForegroundColour);

_grfx.DrawString(_tasklistItem.Text, _tasklistItem.Font, optionTitle_brush,
27 * _grfx.DpiY / DESIGNSIZE,

y + (2 * _grfx.DpiY / DESIGNSIZE));

if (paint_b)

{

//repaint this item.

Invalidate(new Rectangle(0, y, Width, _tasklistItem.Height));

}

optionTitle_brush.Dispose();

}



Cheers

Simon.

"Graham McKechnie" <gmknospam@xxxxxxxxxxxxxx> wrote in message
news:OsfLLjI$FHA.1288@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>


.



Relevant Pages

  • Resolution changes with VS2005
    ... It would appear the resolution changes required for all controls that are on ... This is the new mechanism that is used to kick off automatic scaling. ... this.lightSteelBlueBrush = new SolidBrush(Color.LightSteelBlue); ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Print Vertical Line
    ... borders and controls and replace them all with the line method. ... will have to factor in the output device resolution. ... I'm using line method to print vertical line in report. ...
    (microsoft.public.access.reports)
  • Re: Cant get full page
    ... This is controlled by the website. ... compatibility were designed for a resolution of 800x600 while many people ... Internet Explorer, go to Tools, select Internet Options, on the General Tab, ... > monitor controls but the page just "stretches". ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: Bitmaps in picture controls are clipped when run on some machines but not others
    ... and their controls resize based on display resolution, the display driver, the phase of ... One is to place the picture controls so they can be easily resized without affecting other ... really ugly images if there is fine detail or a significant change in resolution. ...
    (microsoft.public.vc.mfc)
  • Re: resizing controls on the fly
    ... No self-sizing controls. ... "resizing controls" that you just plop on a form and they attempt to resize ... have to do is move the container as appropriate. ... designing at a high resolution and having to scale down ...
    (microsoft.public.vb.controls)