In FMX, I could simply use the TScreen
class from the FMX.Forms
unit and have a function like this:
function GetScreenResolution: String;
begin
Result := Screen.Width.ToString + 'x' + Screen.Height.ToString;
end;
But that doesn't work in TMS Web Core. I can however do the following code which is a mix between Delphi and JavaScript:
function GetScreenResolution: String;
begin
asm
Result = screen.width + "x" + screen.height;
end;
end;
The above does work, but is there a better Delphi-only way instead of mixing the two languages?
You can use window.screen
from the WEB
unit:
function GetScreenResolution: String;
begin
Result := String(window.screen['width']) + 'x' + String(window.screen['height']);
end;