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

Langage Delphi Discussion :

InputQuery


Sujet :

Langage Delphi

  1. #1
    Membre à l'essai
    Inscrit en
    Novembre 2003
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Novembre 2003
    Messages : 19
    Points : 10
    Points
    10
    Par défaut InputQuery
    Bonjour,

    N'y a-t-il pas moyen de personaliser la fenêtre InputQuery, je voudrais jouer avec la longueur de l'edit qui s'y trouve.

  2. #2
    Membre éprouvé
    Avatar de Andry
    Profil pro
    Informaticien
    Inscrit en
    Juillet 2002
    Messages
    1 164
    Détails du profil
    Informations personnelles :
    Localisation : Madagascar

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 164
    Points : 1 181
    Points
    1 181
    Par défaut
    Bah,
    Tu n'as qu'a le creer avec toutes les personalisation que tu veux.
    C'est juste d'une Fiche avec quelques fonction.

    A+

  3. #3
    Membre à l'essai
    Inscrit en
    Novembre 2003
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Novembre 2003
    Messages : 19
    Points : 10
    Points
    10
    Par défaut
    Oui, c'est ce que je voulais faire mais je n'arrive pas à bloquer l'accès à la fenêtre principale pendant que l'autre est ouverte. En fait je voudrais bien que mon application attende que je ferme cette fenêtre avant de continuer. Et mieux encore, lui retourner le texte saisi et le boolean comme le fait InputQuery...

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2003
    Messages
    560
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2003
    Messages : 560
    Points : 576
    Points
    576
    Par défaut
    Bonjour,

    vous devez utiliser Show. Essayer ShowModal.

  5. #5
    Membre expert
    Avatar de e-ric
    Homme Profil pro
    Apprenti chat, bienfaiteur de tritons et autres bestioles
    Inscrit en
    Mars 2002
    Messages
    1 561
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Apprenti chat, bienfaiteur de tritons et autres bestioles

    Informations forums :
    Inscription : Mars 2002
    Messages : 1 561
    Points : 3 955
    Points
    3 955
    Par défaut
    Bonjour

    C'est mon jour de bonté. Cela m'a pris 10 minutes plus que la rédaction de ce message, on se demande même pourquoi Borland l'a fait avant.

    C'est une base de travail, tu peux dorénavant la personnaliser selon tes besoins.

    Pour la récupérer, tu crées d'abord une fiche sans rien dedans que tu enregistres sous le nom InputQueryFrm_F.pas, tu passes en vue texte du dfm (Alt+F12) et tu copies le dfm suivant :

    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
     
    object InputQueryFrm: TInputQueryFrm
      Left = 164
      Top = 221
      BorderStyle = bsSingle
      Caption = 'InputQueryFrm'
      ClientHeight = 88
      ClientWidth = 394
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      DesignSize = (
        394
        88)
      PixelsPerInch = 96
      TextHeight = 13
      object LabelLegende: TLabel
        Left = 8
        Top = 8
        Width = 54
        Height = 13
        Caption = '<Légende>'
      end
      object EditInput: TEdit
        Left = 8
        Top = 28
        Width = 375
        Height = 21
        Anchors = [akLeft, akTop, akRight]
        TabOrder = 0
      end
      object BitBtnOk: TBitBtn
        Left = 222
        Top = 56
        Width = 75
        Height = 25
        Anchors = [akTop, akRight]
        TabOrder = 1
        Kind = bkOK
      end
      object BitBtnCancel: TBitBtn
        Left = 306
        Top = 56
        Width = 75
        Height = 25
        Anchors = [akTop, akRight]
        TabOrder = 2
        Kind = bkCancel
      end
    end
    (attention c'est du Delphi 6 et il y a parfois des différences entre les versions pour les dfm).

    Ensuite tu reviens en mode Fiche (bascule Alt+F12) de façon à pouvoir copier le code suivant :

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
     
    unit InputQueryFrm_F;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons;
     
    type
      TInputQueryFrm = class(TForm)
        EditInput: TEdit;
        BitBtnOk: TBitBtn;
        BitBtnCancel: TBitBtn;
        LabelLegende: TLabel;
        procedure FormCreate(Sender: TObject);
      private
        function GetInput: String;
        function GetLegende: String;
        procedure SetInput(const Value: String);
        procedure SetLegende(const Value: String);
        { Déclarations privées }
      public
        { Déclarations publiques }
        property Legende: String read GetLegende write SetLegende;
        property Input: String read GetInput write SetInput;
      end;
     
    var
      InputQueryFrm: TInputQueryFrm;
     
    function MyInputQuery(const _Caption, _Legende : String; var _Input : String): boolean;
     
     
    implementation
     
    {$R *.dfm}
     
    function MyInputQuery(const _Caption, _Legende : String; var _Input : String): boolean;
    begin
      with TInputQueryFrm.Create(Application) do
      begin
        try
          Caption := _Caption;
          Legende := _Legende;
          Input := _Input;
          Result := ShowModal = BitBtn1.ModalResult;
          if Result then
            // Récupère la saisie si l'utilisateur confirme sa saisie  
            _Input := Input;
          // if
        finally
          Realease;
        end; // try
      end; // with
    End; // MyInputQuery
     
    { TInputQueryFrm }
     
    function TInputQueryFrm.GetInput: String;
    begin
      Result := EditInput.Text;
    end;
     
    function TInputQueryFrm.GetLegende: String;
    begin
      Result := LabelLegende.Caption;
    end;
     
    procedure TInputQueryFrm.SetInput(const Value: String);
    begin
      EditInput.Text := Value;
    end;
     
    procedure TInputQueryFrm.SetLegende(const Value: String);
    begin
      LabelLegende.Caption := Value;
    end;
     
    procedure TInputQueryFrm.FormCreate(Sender: TObject);
    begin
        Legende := '';
    end;
     
    end.
    Et cela devrait marcher.

    Cordialement

    e-ric

  6. #6
    Membre éprouvé
    Avatar de Andry
    Profil pro
    Informaticien
    Inscrit en
    Juillet 2002
    Messages
    1 164
    Détails du profil
    Informations personnelles :
    Localisation : Madagascar

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Juillet 2002
    Messages : 1 164
    Points : 1 181
    Points
    1 181
    Par défaut
    Tiens voici un code que j'utilise. 2 fiches dont l'un appelle l'autre :
    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
     
    type
      TFrm_input = class(TForm)
        Ed_input	: TEdit;
        procedure Ed_inputKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
      public
        { Déclarations publiques }
        procedure _Execute(Var TextInput : String);
      end;
     
    var
      Frm_input TFrm_input 
     
    implementation
     
    uses U_data;
     
    {$R *.dfm}
     
     
    procedure TFrm_input._Execute(Var TextInput : String);
    begin
      ShowModal;
      TextInput := Ed_input.text;
    end;
     
     
    procedure TFrm_input.Ed_inputKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    begin
      //Gestion des appui sur les touches Entrée et Echap 	
      if Key = VK_RETURN then
        ModalResult := mrOk
      else
        if Key = VK_ESCAPE then
          ModalResult := mrCancel;
    end;
    Maintant le code pour apeller notre nouvelle input query.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    Var
      Frm_input : TFrm_input;
      Txt          : String;
    begin
      Frm_input := TFrm_input.Create(Nil);
      try
        Frm_input._Execute(txt);
        // Ici tu as le texte saisi dans le input form.	
      finally
        Frm_input.Release;
      end;
    end;

Discussions similaires

  1. Listbox et InputQuery
    Par lolomathieu dans le forum Débuter
    Réponses: 2
    Dernier message: 23/05/2011, 19h48
  2. Réponses: 7
    Dernier message: 09/09/2009, 09h10
  3. ComboBox à l'intérieur de "InputQuery"
    Par Just-Soft dans le forum Langage
    Réponses: 1
    Dernier message: 15/12/2008, 09h45
  4. Réponses: 4
    Dernier message: 14/05/2008, 14h35
  5. InputQuery n'affichant pas les caractères saisies
    Par netah25 dans le forum C++Builder
    Réponses: 2
    Dernier message: 18/01/2007, 11h03

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