Home > Blockchain >  Delphi change scale and layout
Delphi change scale and layout

Time:01-23

I'm trying to make my program change the layout scale at runtime. I developed this code based on an existing powershell script. But it compiles but when running, it returns an error.

Error: The procedure entry point SystemParametersInfo could not be located in the dynamic link library.

var
  Form1: TForm1;

  function SystemParametersInfo(uiAction, uiParam: UINT; pvParam: Pointer; fWinIni: UINT): BOOL; stdcall; external 'user32.dll';

implementation

{$R *.dfm}

function SetScaling: Boolean;
begin
 Result := SystemParametersInfo($000F, 125, nil, 1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 SetScaling;
end;

CodePudding user response:

As it is said in the mentioned error there is no function named SystemParametersInfo in user32.dll.

There are two similarly named functions SystemParametersInfoA which is to be used by applications that work with ANSI strings and SystemParametersInfoW which is to be used by applications supporting wide strings like modern Delphi.

NOTE: SystemParametersInfo can only be found on Windows CE 5.0 and it resides in Coredll.lib library.

CodePudding user response:

The WinAPI.Windows unit defines the SystemParametersInfo function. No reason to define it locally.

Your call to SystemParametersInfo with a first parameter of $000F is a request to set the screen saver timeout to 125 seconds ($000F=SPI_SETSCREENSAVETIMEOUT).

Setting DPI Scaling is a bit more complex than what you are attempting in the code that you posted. You can read the "how-to" details here.

  • Related