Einzelnen Beitrag anzeigen

Darlo

Registriert seit: 28. Jul 2008
Ort: München
1.196 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#5

AW: Firemonkey iPad & iPhone in einer App

  Alt 12. Okt 2012, 08:09
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 = 'iPhonethen
      if format = 'Hochformatthen
        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 = 'iPadthen
      if format = 'Hochformatthen
        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
Philip
  Mit Zitat antworten Zitat