Handling Different screen sizes

W

Will Chapman

What is the best way to allow for different
screen sizes on, say, the standard PocketPC
format and the square 240x240 screen size
of the Ipaq hw 6515?

The form I have in my app is too complex to
simply write code to scrunch up the screen
and resize controls.

On the surface it seems that the easiest option
would be to create forms for each screen size and
then write code that will choose the correct size at
runtime. That would suggest that, to avoid repetitive
code in both forms, I should create a custom control
that inherits from System.Windows.Form.Form and,
being new to C#, that constitutes a big leap in skill;
are there any walkthroughs available that cover
form inheritance? Or, indeed, is there a better way to
handle multiple screen sizes?

Thanks...

Will Chapman
 
W

Will Chapman

Will said:
runtime. That would suggest that, to avoid repetitive
code in both forms, I should create a custom control
that inherits from System.Windows.Form.Form and,
being new to C#, that constitutes a big leap in skill;
are there any walkthroughs available that cover
form inheritance? Or, indeed, is there a better way to
handle multiple screen sizes?

To respond partially to my own question, I've been
experimenting with the Inherited Form template and
immediately came up with Visual Inheritance problems
....this looks like its going to be fun but at least with a
coupe of new key phrases to search on I've got a better
chance of finding a walkthrough/tutorial.
 
M

Michael Lang

I'd stay away from inheritance....

Why don't you simply develop your application as an N-Tier app...
Keep your forms very light and with as little code as possible...

Have a business layer class library independent of each form...

Then each form can get an instance of your business object and pass on it's
events to the business object....
The business object then keeps the state of the form and processes events as
they occur.
 
W

Will Chapman

Michael said:
I'd stay away from inheritance....

Why don't you simply develop your application as an N-Tier app...
Keep your forms very light and with as little code as possible...

Have a business layer class library independent of each form...
Thats an interesting approach; one of the problems I have is
I am just getting familar with C# and techniques like this aren't
yet second nature.

I'll give it a shot.

Thanks for the input,

Will Chapman

Then each form can get an instance of your business object and pass
on it's events to the business object....
The business object then keeps the state of the form and processes
events as they occur.

--
Cheers.......


Will Chapman
nb Quidditch
 
R

Robert Levy [MS]

Something to watch out for is making sure you gracefully handle the switch
between Landscape and Portrait modes at any time while your app is being
used. That's pretty hard to do well when doing the "multiple form"
approach. My recommendation is to stick with a single form and write code
that moves/resizes controls to be where you want them for each screen size.
If docking & anchoring doesn't meet your needs, try the technique described
in the first half of
http://msdn.microsoft.com/library/d...ing_orientation_and_resolution_aware_apps.asp
 
W

Will Chapman

Robert said:
you want them for each screen size. If docking & anchoring doesn't
meet your needs, try the technique described in the first half of
http://msdn.microsoft.com/library/d...ing_orientation_and_resolution_aware_apps.asp
Robert

That article was just what I needed. For the record I have two forms, one
is a 'registration' form frmSelect that only runs if some Registry settings
are
absent and frmPPC which opens when the settings are present. The settings
include the Device Type:
static void Main()
{
C4B.C4BRegistry oReg = new C4B.C4BRegistry();
switch (oReg.GetStringValue("Device Type", ""))
{
case "":
Application.Run(new frmSelect());
break;
default:
Application.Run(new frmPPC());
break;
}

When frmPPC opens the Registry is checked again and
depending on the type of Device (in this example just
screen size) a function sets the screen layout.

This code replaces frmPPC.InitializeComponent as the
functions Square and PocketPC are direct cut&pastes
of the contents of InitializeComponent's generated for
each target device.

switch (oReg.GetStringValue("Device Type", "PPC 2003"))
{
case "hw 6515":
Square();
break;
case "PPC 2003":
PocketPC();
break;
default:
break;
}

Simple, but effective.


Thanks for your input....

Will Chapman

--
Cheers.......


Will Chapman
nb Quidditch
 

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