Forum > LCL

Panel displaying differently on lower resolutions


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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.showToast(mes: String);begin  //reset toast panel timers  ToastTimet1.enabled:=false;  ToastTimer2.enabled:=false;  ToastPanel.visible:=false;   //set the toast message to the passed in variable  ToastMessage:=mes;   ToastPanel.visible:=true; ToastLabel.Caption:=toastMessage; ToastPanel.width:=toastlabel.width+100; ToastPanel.height:=40;  Toastpanel.Left := (ClientWidth - toastpanel.Width) div 2; //centre horiz panel on screen ToastLabel.Left := (ToastPanel.width - Toastlabel.Width) div 2; //centre horiz label on panel    //start the toast process  ToastTimet1.enabled:=true; end;  

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"?

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?

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.

Oh my! thank you!
Cant believe it was so simple!


[0] Message Index

Go to full version