Re: resizing controls for different Windows DPIs

new topic     » goto parent     » topic index » view thread      » older message » newer message

don cole wrote:
> 
> Pete Stoner wrote:
> > 
> >    I asked this question some time ago but didn't get any replies so I'll
> >    try again smile
> >    I have programs written using Win32lib, all the controls are sized to
> >    look
> > good on my 96dpi screen, when I run them on my laptop which is set to 120dpi
> > the text becomes too large for its container (buttons, text boxes etc). I
> > had
> > a peek at some commercial (and freeware) programs using WinSpy and the sizes
> > of all the containers (including the window itself) have different sizes on
> > 96 and 120dpi. Even WinSpy itself does this..
> > 
> > I tried wrapping the stuff to use dialog units instead of pixels which works
> > sometimes(!) but it's not reliable enough, I also tried using Fixed fonts
> > but
> > these also grow with higher DPI. I see this problem as a major drawback to
> > creating
> > EU applications which will be passed to other users who could be using a
> > different
> > DPI to you, especially as displays improve and the DPIs available increase.
> > The end result is your app looks unprofessional and even could be unusable.
> > 
> > How do other programs (commercial or otherwise) cope with this? and is there
> > any way we can use the same technique with Euphoria? (unless it is just
> > getting
> > the DPI the system is using and having a long list of different
> > sizes/positions
> > for every control!! sad  )
> > 
> > regards PeteS
> 
> I don't really know what dpi is. I suppose it has something to do with pixels
> per inch.
> Can't you measure screen size with something like getClientRec() and then
> adjust
> all control sizes  based on a ratio of that?
> Also isn't wxEuphoria supposed to handle that suff automatically?
> I don't have a laptop so I don't have any experiance with different dpis.
> I hope this will help some,
> 
> Don Cole


I may be onto something, I've been searching the web for 'Device-independent
units' that I saw mentioned somewhere, trying to find a formula.. I found 2
possibles that really amount to the same thing

DeviceValue = Co-ordinate_Value * (DPI/72)
and
PixelSize = PointSize * Device Resolution/72.27

Using this (along with w32Func(xGetDeviceCaps,{getDC(Screen),LOGPIXELSY}) from
win32lib to get the device DPI) seemed to get the 'auto-resize' working but not
quite as desired. I then found mentioned (somewhere on my travels!) dividing the
Device DPI by the Logical DPI. assuming the logical DPI to be the DPI you have
set when developing the app I used 96 and the resizing looks pretty good now..

Gonna need more testing yet as I thought I had it cracked last time using Dialog
Units...

PeteS

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu