Recent

Author Topic: Panel displaying differently on lower resolutions  (Read 1350 times)

irfan

  • Newbie
  • Posts: 3
Panel displaying differently on lower resolutions
« on: May 08, 2021, 01:39:43 pm »
Hey!
I am making a simple toast message pop up using timers and disappear after few seconds. The message is basically a label on a panel.
When testing the application on lower resolutions, the panel has a very elongated height! not sure why!
Here is the code, im pretty basic at all this !
Ive also attached images of the toast message in 2 different resolutions 1080x1920 and a lower one.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.showToast(mes: String);
  2. begin
  3.   //reset toast panel timers
  4.   ToastTimet1.enabled:=false;
  5.   ToastTimer2.enabled:=false;
  6.   ToastPanel.visible:=false;
  7.  
  8.   //set the toast message to the passed in variable
  9.   ToastMessage:=mes;
  10.  
  11.  
  12.  ToastPanel.visible:=true;
  13.  ToastLabel.Caption:=toastMessage;
  14.  ToastPanel.width:=toastlabel.width+100;
  15.  ToastPanel.height:=40;
  16.  
  17.  Toastpanel.Left := (ClientWidth - toastpanel.Width) div 2; //centre horiz panel on screen
  18.  ToastLabel.Left := (ToastPanel.width - Toastlabel.Width) div 2; //centre horiz label on panel
  19.  
  20.  
  21.   //start the toast process
  22.   ToastTimet1.enabled:=true;
  23.  
  24. end;  

wp

  • Hero Member
  • *****
  • Posts: 8740
Re: Panel displaying differently on lower resolutions
« Reply #1 on: May 08, 2021, 01:50:26 pm »
Could you prepare a little demo project which shows the issue and upload it here? (only .lpr, lpr, lfm and .pas files packed into a common zip, no exe and other compiler-generated files). I doubt that the issue has anything to do with the screen resolution.

Just to make sure that LCL scaling is not involved: Your two screenshots have the same font sizes; therefore I guess that your two monitors have the same pixels-per-inch settings. Correct? If not is LCL scaling active (checkbox "Use LCL scaling (High DPI)" in "Project" > "Project options"?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

irfan

  • Newbie
  • Posts: 3
Re: Panel displaying differently on lower resolutions
« Reply #2 on: May 08, 2021, 02:16:28 pm »
AH, so regardless of resolution, the issue happens when the form height is reduced from its 100% value. (i tested it by simply dragging to make the form smaller at runtime.)
Does this help with a possible solution?

wp

  • Hero Member
  • *****
  • Posts: 8740
Re: Panel displaying differently on lower resolutions
« Reply #3 on: May 08, 2021, 03:35:01 pm »
Maybe you anchored the bottom of the panel to the bottom of the form? What are the settings in the panel's Anchors? If akBottom is checked then this behaviour is expected to happen.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

irfan

  • Newbie
  • Posts: 3
Re: Panel displaying differently on lower resolutions
« Reply #4 on: May 08, 2021, 06:34:50 pm »
Oh my! thank you!
solved!
Cant believe it was so simple!

 

TinyPortal © 2005-2018