Re: Layout of Dialog (screen resolutions, font sizes etc)
hamishd wrote:
Hi. When I design a dialog, it looks as intended on my computer. I
normally position and size controls at runtime using SetWindowPos().
However, occasionally when running on clinets computers, the layout is
all wrong and looks terrible. I'm not sure if this is because they're
using different fonts or what.
What things do I need to do to ensure my dialog will look the same on
any computer?
(PS: I'm not setting the Font at runtime either. How to do that would
be really useful. Do I need to do it for each control? Can I make my
own control, eg MyComboBox which will always use my intended fint,
rather than whatever their system is using?)
In WinXP experiment and test with Control Panel, Settings, Advanced, DPI
and with Control Panel, Appearance, Font Size. These options are under
the user's control and you should work with them, not fight against
them. If the user makes the font bigger then your dialogs and controls
will automatically become bigger by default.
Why are you using SetWindowPos for each control instead of letting the
defaults work? That may be your basic problem. SetWindowPos works in
units of pixels, but all dialogs and controls are stored and rendered in
'dialog units' by Windows so they will be scaled for different screen
resolutions, fonts and DPI.
You can set the font used by any standard control by calling its SetFont
function. Each control must be set separately. But this won't make
them look the same on all computers unless you adjust the font for the
screen characteristics.
--
Scott McPhillips [VC++ MVP]