IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants FMX Delphi Discussion :

FMX creation Form2


Sujet :

Composants FMX Delphi

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2009
    Messages
    349
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2009
    Messages : 349
    Par défaut FMX creation Form2
    Bonjour
    je viens m'apercevoir que sous FMX
    je ne vois pas comment faire apparaitre une
    deuxième fenêtre (Tform2) et de l'appeler avec Showmodal
    sa existe ou pas
    si dans la négative comment vous faire pour
    faire apparaitre
    exemple: un formulaire a remplir ou une fiche pour cocher
    des options

    merci encore a vous tous

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2009
    Messages
    349
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2009
    Messages : 349
    Par défaut
    bonjour
    je viens de voir qu'on le remplace par des popups
    avez des exemples comment sa marche
    merci

  3. #3
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    678
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2017
    Messages : 678
    Billets dans le blog
    1
    Par défaut
    Oui, FMX supporte bien ShowModal, mais son comportement varie selon la plateforme (Windows ou Mobile).

    https://docwiki.embarcadero.com/Libr...Form.ShowModal

    sur Windows FMX se comporte comme VCL : ShowModal fonctionne de façon synchrone et vous pouvez créer/afficher TForm2 puis récupérer ModalResult. Sur mobile il faut préférer l’overload asynchrone ou des alternatives (frames/popups).

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    var
      Form2: TForm2;
    begin
      Form2 := TForm2.Create(nil);
      try
        if Form2.ShowModal = mrOk then
          // récupérer valeurs depuis Form2
      finally
        FreeAndNil(Form2);
      end;
    end;
    je viens de voir qu'on le remplace par des popups
    avez des exemples comment sa marche
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    procedure TForm1.ShowOptionsPopup(Sender: TObject);
    var
      P: TPopup;
      L: TLayout;
      CB1, CB2: TCheckBox;
      BtnOK, BtnCancel: TButton;
    begin
      // Création du popup
      P := TPopup.Create(Self);
      P.Parent := Self; 
      P.PlacementTarget := Sender as TControl;
      P.Placement := TPlacement.Bottom;
      P.HorizontalOffset := 0;
      P.VerticalOffset := 6;
     
      // Conteneur pour mise en page
      L := TLayout.Create(P);
      L.Parent := P;
      L.Align := TAlignLayout.Top;
      L.Padding.Rect := TRectF.Create(8,8,8,8);
     
      // Checkboxes
      CB1 := TCheckBox.Create(P);
      CB1.Parent := L;
      CB1.Position.Y := 4;
      CB1.Text := 'Option A';
     
      CB2 := TCheckBox.Create(P);
      CB2.Parent := L;
      CB2.Position.Y := CB1.Position.Y + 36;
      CB2.Text := 'Option B';
     
      // Boutons
      BtnOK := TButton.Create(P);
      BtnOK.Parent := L;
      BtnOK.Position.Y := CB2.Position.Y + 44;
      BtnOK.Text := 'OK';
      BtnOK.OnClick := 
        procedure(Sender2: TObject)
        begin
          // Récupérer valeurs et fermer
          if CB1.IsChecked or CB2.IsChecked then
          begin
            Self.Tag := Integer(CB1.IsChecked) or (Integer(CB2.IsChecked) shl 1);
          end;
          P.IsOpen := False;
          P.Free;
        end;
     
      BtnCancel := TButton.Create(P);
      BtnCancel.Parent := L;
      BtnCancel.Position.Y := BtnOK.Position.Y;
      BtnCancel.Position.X := BtnOK.Position.X + 90;
      BtnCancel.Text := 'Annuler';
      BtnCancel.OnClick := 
        procedure(Sender2: TObject)
        begin
          P.IsOpen := False;
          P.Free;
        end;
     
      // Ouvrir le popup
      P.IsOpen := True;
    end;
    On ne peut pas faire confiance à un code qu'on n'a pas entièrement écrit soi‑même, et encore moins à celui qu'on a écrit entièrement. :aie:

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2009
    Messages
    349
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2009
    Messages : 349
    Par défaut
    bonsoir
    merci commence a comprendre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
     
    unit Unit1;
     
    interface
     
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
      FMX.Controls.Presentation, FMX.Objects;
     
    type
      TForm1 = class(TForm)
        Popup1: TPopup;
        Button1: TButton;
        Panel1: TPanel;
        Label1: TLabel;
        popbut: TButton;
        Rectangle1: TRectangle;
        Label2: TLabel;
        procedure popbutClick(Sender: TObject);
        procedure Button1Click(Sender: TObject);
     
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.fmx}
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     form1.Popup1.ModalResult:=mrok;
     form1.Popup1.IsOpen:=false;
    end;
     
    procedure TForm1.popbutClick(Sender: TObject);
     
    begin
     form1.Popup1.PopupModal;
    end;
     
    end.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'Form1'
      ClientHeight = 480
      ClientWidth = 640
      FormFactor.Width = 320
      FormFactor.Height = 480
      FormFactor.Devices = [Desktop]
      DesignerMasterStyle = 0
      object Popup1: TPopup
        PlacementTarget = Label2
        Position.X = 150.000000000000000000
        Position.Y = 88.000000000000000000
        Size.Width = 329.000000000000000000
        Size.Height = 289.000000000000000000
        Size.PlatformDefault = False
        TabOrder = 0
        object Rectangle1: TRectangle
          Align = Client
          Fill.Color = claAntiquewhite
          Size.Width = 329.000000000000000000
          Size.Height = 289.000000000000000000
          Size.PlatformDefault = False
          object Button1: TButton
            Position.X = 120.000000000000000000
            Position.Y = 34.000000000000000000
            TabOrder = 0
            Text = 'Button1'
            TextSettings.Trimming = None
            OnClick = Button1Click
          end
          object Label1: TLabel
            Position.X = 24.000000000000000000
            Position.Y = 264.000000000000000000
            Size.Width = 281.000000000000000000
            Size.Height = 17.000000000000000000
            Size.PlatformDefault = False
            Text = 'Label1'
            TabOrder = 1
          end
          object Panel1: TPanel
            Position.X = 24.000000000000000000
            Position.Y = 64.000000000000000000
            Size.Width = 281.000000000000000000
            Size.Height = 201.000000000000000000
            Size.PlatformDefault = False
            TabOrder = 2
          end
        end
      end
      object popbut: TButton
        Position.X = 40.000000000000000000
        Position.Y = 40.000000000000000000
        TabOrder = 1
        Text = 'pop'
        TextSettings.Trimming = None
        OnClick = popbutClick
      end
      object Label2: TLabel
        Position.X = 176.000000000000000000
        Position.Y = 48.000000000000000000
        Text = '*'
        TabOrder = 2
      end
    end

    donc résolu pour instant
    merci a tous

  5. #5
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 796
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 796
    Billets dans le blog
    65
    Par défaut
    Bonjour,

    Personnellement, avec FMX mais aussi VCL , j'ai pris en horreur les showmodals ou même show.
    J'ai écrit à ce sujet un article https://serge-girard.developpez.com/...elphi/Docking/ sur les différentes formes d'enchainements de formulaires.

    Dernièrement,sous Android,un Show (oublié) m'a surpris, en se comportant comme un showmodal. Cependant je n'ai pas poussé l'expérience au delà d'une fenêtre. C'est un des points que je dois éclaircir avant de publier un nouvel article sur les styles
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes), D13 (Florence)
    SGBD : Firebird 2.5, 3, 5 et SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

Discussions similaires

  1. Réponses: 1
    Dernier message: 03/11/2006, 22h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo