Bonjour à tous.
L'exemple suivant montre comment les fiches d'une application, s'affichent comme des pages coulissantes.
Sur une fiche principale(Form1) on ajoute:
Un ToolBar1 contenant ToolButton1(caption:Form2),ToolButton2(caption:Form3) et ToolButton3(caption:Form4).
Un Timer1 (Enabled:False, Interval:100).
On ajoute ensuite 3 Fiches:Form2, Form3 et Form4 dont les units (interface/uses comportent Unit1).
1) Déclaration de la procedure.
2) Déclaration de variable i.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 interface //Form1. uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, Menus, ExtCtrls; Procedure Largeur(Form:TForm);
3) Implémentation des unités.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 var Form1: TForm1; i:integer;
4) implémentation de la procédure.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 implementation uses Unit2,Unit3,Unit4; {$R *.lfm} { TForm1 }
5) Initialisation de la fiche principale.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 procedure Largeur(Form:TForm); begin Form.BorderStyle:=bsNone ; Form.Top:=120; // ou un nombre de votre choix. Form.Left:=4; form.height:=screen.Height-160 ; Form.width:=0; Form1.Timer1.enabled:=true end;
6) Initialisation de i.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 procedure TForm1.FormActivate(Sender: TObject); begin Form1.Top:=2; Form1.Left:=2; Form1.height:=screen.Height-40 ; Form1.width:=screen.Width-15 ; end;
7) Implémentation de Timer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 procedure TForm1.Timer1StartTimer(Sender: TObject); begin i:=0 end;
8) Implémentation des ToolButtons.
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 procedure TForm1.Timer1Timer(Sender: TObject); begin if i<4 then begin screen.ActiveForm.Width:=i*400 ; i:=i+1; end else begin screen.ActiveForm.Width:=screen.Width-13 ; i:=0; timer1.Enabled:=false ; end; screen.ActiveForm.FormStyle:=fsStayOnTop ; end;
merci à tous.
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 procedure TForm1.ToolButton1Click(Sender: TObject); begin Largeur(Form2); Form2.Show; end; procedure TForm1.ToolButton2Click(Sender: TObject); begin Largeur(Form3); Form3.show; end; procedure TForm1.ToolButton3Click(Sender: TObject); begin Largeur(Form4); Form4.show; end;![]()
Partager