billionjk 0 Posted January 29 (edited) I created a simple project with one panel and one button in Form. Click on the button will create a panel component with the same size as the panel at design time. But why the result of the panel that crates at runtime is smaller than the panel created at design time? I'm using Delphi 10.4.2 The size of Panel1 is 250x350 pixels. I set the size of pnlRuntime to 250x350 pixels same as Panel1. procedure TForm1.Button1Click(Sender: TObject); var pnlRuntime: TPanel; begin pnlRuntime := TPanel.Create(Form1); pnlRuntime.Parent := Form1; pnlRuntime.left := 265; pnlRuntime.top := 8; pnlRuntime.Height := 350; pnlRuntime.Width := 250; end; When running the project and clicking Button1. Why the size of the new panel is smaller than Panel1? Edited January 29 by billionjk Share this post Link to post
billionjk 0 Posted January 29 1 minute ago, dwrbudr said: What is the DPI your monitor runs at? How to check it? I don't know about DPI. Share this post Link to post
dwrbudr 8 Posted January 29 Try pnlRuntime.Height := MulDiv(350, Screen.PixelsPerInch, 96); Share this post Link to post
billionjk 0 Posted January 29 procedure TForm1.Button1Click(Sender: TObject); var pnlRuntime: TPanel; begin pnlRuntime := TPanel.Create(Form1); pnlRuntime.Parent := Form1; pnlRuntime.left := 265; pnlRuntime.top := 8; // pnlRuntime.Height := 350; // pnlRuntime.Width := 250; pnlRuntime.Height := MulDiv(350, Screen.PixelsPerInch, 96); pnlRuntime.Width := MulDiv(250, Screen.PixelsPerInch, 96); end; After changing the code as dwrbubr suggested. The size going equals the design time. How about the position? and How about the third parameter of 96 in MulDiv(350, Screen.PixelsPerInch, 96)? Share this post Link to post
dwrbudr 8 Posted January 29 Use the same calculations for Left and Top. 96 is the default screen pixels per inch at 100% scaling, e.g. Screen.DefaultPixelsPerInch Check your display options in Windows to see what screen scaling you're using, probably 125% or 150% Share this post Link to post
billionjk 0 Posted January 29 50 minutes ago, dwrbudr said: Use the same calculations for Left and Top. 96 is the default screen pixels per inch at 100% scaling, e.g. Screen.DefaultPixelsPerInch Check your display options in Windows to see what screen scaling you're using, probably 125% or 150% After checking my screen scaling it was set to 125% and I changed the scaling to 100%, 150% and 175% the components on the form are scaled correcting. Thank you so much. Share this post Link to post