Hi,
ich mache das so:
Mainform mit Layout alClient.
Folgender Code wird im Resize des Layouts und im Create der Form ausgeführt:
Delphi-Quellcode:
procedure TfrmMain.FormResize(Sender: TObject);
begin
if frmPhoneQuer = nil then exit;
if frmPadHoch = nil then exit;
if frmPadQuer = nil then exit;
loadView(sender);
end;
Delphi-Quellcode:
function TfrmMain.loadView(Sender: TObject): boolean;
begin
try
if frmMain.Width+frmMain.Height > 1010 then
begin
mydevice := 'iPad';
laHilfe.Visible := false;
laInfo.Visible := false;
end
else
mydevice := 'iPhone';
if frmMain.layoutContent.Width > frmMain.layoutContent.Height then
format := 'Querformat'
else
format := 'Hochformat';
if myDevice = 'iPhone' then
if format = 'Hochformat' then
begin
frmMain.layoutMain.Parent := frmMain.layoutContent;
frmMain.layoutMain.Visible := true;
frmPhoneQuer.layoutPhoneQuer.Visible := false;
frmPadHoch.layoutPadHoch.Visible := false;
frmPadQuer.layoutPadQuer.Visible := false;
laHilfe.Visible := true;
laInfo.Visible := true;
end
else
begin
frmPhoneQuer.layoutPhoneQuer.Parent := frmMain.layoutContent;
laHilfe.Visible := false;
laInfo.Visible := false;
frmMain.layoutMain.Visible := false;
frmPhoneQuer.layoutPhoneQuer.Visible := true;
frmPadHoch.layoutPadHoch.Visible := false;
frmPadQuer.layoutPadQuer.Visible := false;
end;
if myDevice = 'iPad' then
if format = 'Hochformat' then
begin
frmPadHoch.layoutPadHoch.Parent := frmMain.layoutContent;
frmMain.layoutMain.Visible := false;
frmPhoneQuer.layoutPhoneQuer.Visible := false;
frmPadHoch.layoutPadHoch.Visible := true;
frmPadQuer.layoutPadQuer.Visible := false;
frmPadHoch.swSwitch(frmPadHoch.swTarif);
frmPadHoch.swSwitch(frmPadHoch.swKstPflicht);
frmPadHoch.swSwitch(frmPadHoch.swKstSatz);
end
else
begin
frmPadQuer.layoutPadQuer.Parent := frmMain.layoutContent;
frmMain.layoutMain.Visible := false;
frmPhoneQuer.layoutPhoneQuer.Visible := false;
frmPadHoch.layoutPadHoch.Visible := false;
frmPadQuer.layoutPadQuer.Visible := true;
frmPadQuer.swSwitch(frmPadQuer.swTarif);
frmPadQuer.swSwitch(frmPadQuer.swKstPflicht);
frmPadQuer.swSwitch(frmPadQuer.swKstSatz);
end;
frmMain.Height := TRUNC(frmMain.layoutHead.Height+
frmMain.layoutContent.Height+
frmMain.layoutBottom.Height);
frmMain.Width := TRUNC(frmMain.layoutHead.Width);
//Nur für PC
frmMain.ClientHeight := TRUNC(frmMain.layoutHead.Height+
frmMain.layoutContent.Height+
frmMain.layoutBottom.Height);
frmMain.ClientWidth := TRUNC(frmMain.layoutHead.Width);
result := true;
except
result := false;
end;
end;
Habe es noch nicht mit dem iPhone 5 getestet.
Gruß
Philip