[Lazarus] Resolution changes ?

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Jul 23 12:34:34 CEST 2015


On 2015-07-23 10:43, Michael Van Canneyt wrote:
> 
> What is the recommended way to deal with changes in resolution for a lazarus program ?

When you say "resolution" change, do you mean desktop resolution or DPI
change?


> I designed an application on Linux, on a 27" monitor. 

What DPI is your Linux system using? I know it is the wrong thing to do,
but I force my development systems to 96 dpi. Then in my fpGUI
applications I scale the forms, controls and fonts based (using one
simple functions in OnShow) based on the current system's dpi value
compared to the "designed system's dpi". The same code should work for
LCL - I can share if you want.

eg:
  http://geldenhuys.co.uk/~graemeg/project2-96dpi.png
  http://geldenhuys.co.uk/~graemeg/project2-80dpi.png
  http://geldenhuys.co.uk/~graemeg/project2-107dpi.png
  http://geldenhuys.co.uk/~graemeg/project2-120dpi.png
  http://geldenhuys.co.uk/~graemeg/project2-140dpi.png


procedure TMainForm.FormShow(Sender: TObject);
begin
  if fpgApplication.Screen_dpi <> cDPI then
    ScaleDPI(self, cDPI); // cDPI is the dpi you designed the form at
end;

Lazarus LFM files don't store the designed DPI value (Kylix and Delphi
did), so I believe you are screwed if the running system's DPI is
different to the designed system. There is no automated way to scale the
forms like Delphi or Kylix could do - unless LCL has some other means of
doing the same.

> All looks well when designing and running the program. 
> All controls nicely spaced, labels large enough to fit their contents.

Simply a change in desktop resolution (eg: 1024x768) shouldn't affect
control spacing or label content not fitting. It will affect if a form
can actually fit 100% inside the available desktop space though.

So from the above I'm assuming your Linux system uses a different DPI
value to the Windows system. The latter is normally set to 96dpi by default.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/




More information about the Lazarus mailing list