Share via


Identifying VGA resolution on WM devices.

Very often when developing managed applications you need to target both VGA (480x640) and the older QVGA (240x320) type of devices. If the AutoScaleMode property of your form is set to Dpi, your controls such as textboxes. labels, buttons etc... will be scaled automatically. However if your draw images yourself or utilizing the ImageList, the images are not going to be autoscaled for you. During the runtime you can easily identify the VGA resolution by using the following code:

  public static bool IsHighResolution(this Form form)

  {

       SizeF currentScreen = form.CurrentAutoScaleDimensions;

       if (currentScreen.Height == 192)

       {

            return true;

  }

       return false;

  }

This is an extension method which is a part of the ControlExtension class from the ListViewDemo project which you can download from here.

So how would you use that method. Here's a sample function that you can place in your form's code:

  private void HandleHiRes()

  {

       if (this.IsHighResolution())

       {

             this.imageList1.ImageSize = new Size(32 * 2, 32 * 2);

       }

  }

Enjoy...