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.
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.
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+
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...
Bonjour,
vous devez utiliser Show. Essayer ShowModal.
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 :
(attention c'est du Delphi 6 et il y a parfois des différences entre les versions pour les dfm).
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
Ensuite tu reviens en mode Fiche (bascule Alt+F12) de façon à pouvoir copier le code suivant :
Et cela devrait marcher.
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.
Cordialement
e-ric
Tiens voici un code que j'utilise. 2 fiches dont l'un appelle l'autre :
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
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;
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;
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager