FormFactor, dynamic user controls and their size

D

davebythesea

Hi folks,

I'm building an app for PPC 2003 using Compact Framework v2.0.

In this app I have a form in which I dynamically create and add custom user
controls. These controls by and large inherit from from things like TextBox,
RadioButton, ComboBox.

Anyway, up till now I've tested my app on a PPC 2003 device (HP iPAQ h6315),
Windows Mobile 6 Pro (HTC Touch, HTC P3300, HP iPAQ 614c) and all has been
fine. They have a screen resolution of 240x320.

However, I installed the app on a HP iPAQ 214 (Windows Mobile 6 Classic)
screen resolution 480x640, and when I open the form with the dynamically
created controls they are all very small in size. Using this device, contorls
which have been added in the designer are fine and adjust correctly to the
new screen resolution. However, dynamically created and added controls in
which i specify the Top,Left,Width, Height etc.. appear reduced by 1/2 size.

If I look at a control on the form placed by the designer it might have a
Left position of say 3. When I run the app and look at this control in
runtime, the control is automatically given a Left position of 6. I would
like to somehow, if possible, make my custom user controls also automatically
adjust based on screen resolution? Is there a property which i can set to do
this? I tried overriding Dock and Anchor and resetting these but it made no
difference :-[ any ideas?

Thanks again,
Dav
 
D

davebythesea

Hi,

I just checked for the Forms width and made the controls smaller or larger
depending on the current width. Thats seems to fix it for the moment.

Dav
 
S

Simon Hart [MVP]

Theres no real solution to this until we have vector based UI/UX. I guess you
are hardcoding the size, location values? The recomended practice is to
design your form at the smallest size then perform a simple calculation no
matter what resolution you are running on.

IE something like this should work for most devices:

dbleBuff.FillRectangle(
new SolidBrush(Color.White),
0, 0, Convert.ToInt32(20 * grfx.DpiY / DESIGNPOINTSPERINCH),
Height);

Where DESIGNPOINTSPERINCH = in this case 96 DPI which is generally device
with a 240 x 320 screen. On a hi-res such as you're iPAQ 214 the DPI is
likely to be 192 dpi. So the above calculation will be 20 * 192 / 96 = 40
instead of 20 when running on 96 dpi devices.

This is a little ugly but it's all we've got ;)
 

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