For those who have read the "How to get Retina working" post, you might have noticed the complications you're running into, as you cannot set the needed Retina value from within your program. It will only be effective after you restart the program.
To do this, the following function that I found at the Lazarus Forum, with a small modification to make it work under MacOS X, works well.
First make sure "Process" is included in your Uses clause.
Then define the "Restart()" procedure, which you can call at any time you'd like. Be careful to not end up in an endless loop though.
procedure Restart;
VAR aProcess : TProcess; //TProcess is crossplatform is best way
begin
aProcess := TProcess.Create(nil);
aProcess.CommandLine := '"'+Application.ExeName+'"';
aProcess.Execute;
aProcess.Free;
Application.Terminate;
end;
Mac specific for Retina:
What I did, sloppy or not, is add the following to the "OnCreate()" event of the main form:
procedure TForm1.FormCreate(Sender: TObject);
var s:AnsiString;
begin
// Retina, requires a restart to become effective.
// First we read if the AppleMagnifiedMode is set or not
RunCommand('/usr/bin/defaults',['read','com.yourcompany.yourapp','AppleMagnifiedMode'],s);
// If set, it returns "Yes" (or possibly 1 or True - no guarantees here)
s:=Uppercase(s);
if (Pos('YES',s)>0) or (Pos('TRUE',s)>0) or (s='1') or (s='') then
begin
RunCommand('/usr/bin/defaults',['write','com.yourcompany.yourapp','AppleMagnifiedMode','NO'],s);
Restart;
end;
...
What we do here: check if AppleMagnifiedMode is activated. If activated, deactivate it and restart.