Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-07

Resolution changes ?

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

What is the recommended way to deal with changes in resolution for a lazarus program ?

I designed an application on Linux, on a 27" monitor. All looks well when designing and running the program. All controls nicely spaced, labels large enough to fit their contents.

I build the program for windows, and run it on a windows computer. It looks horrible. Controls overlapping, labels too short for their contents.

Early versions of Delphi (at least up to XE) had this problem too;
when changing resolution, all is messed up.

What is the recommended way to go about this when using the LCL ?

Michael.

Reply by email

Michael Van Canneyt
to Aradeonas
Aradeonas wrote
Is font same in the both os?

I didn't specify any fonts, I assume it uses the OS default in that case ?

When you resize the form in Linux is all things OK?

Yes.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: What is the recommended way to deal with changes in resolution for a lazarus program ? I…
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/

Reply by email