Sign in Join
Wiki copytemporary

Application full screen mode/fr: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Application full screen mode/fr

OldNewLine
1+## Introduction
2+
3+Quelques applications telles des fouineurs Web permettent de montrer en mode plein écran en utilisant la touche <span class="kbd">F11</span>. En mode plein écran, la fenêtre n'a pas de bordure ni de barre de titre et occupe l'espace entier. La barre de tâche est aussi cachée.
4+
5+Pour être capable de passer en mode plein écran, vous aurez besoin:
6+
7+- de mémoriser l'état antérieur de la fiche tel que la position, la taille et l'état de la fenêtre
8+- d'être capable de déterminer la taille de l'écran
9+- de capturer quelque touche et d'effectuer l'opération
10+
11+La meilleure façon de capturer la touche voulue consiste à utiliser les Actions. Définissez simplement une nouvelle action dans le gestionnaire d'actions et affectez-lui un raccourci-clavier. Ainsi le raccourci fonctionnera même si la fiche perd le focus.
12+
13+## Programme d'exemple
14+
15+``` pascal
16+unit Unit1;
17+
18+{$mode objfpc}{$H+}
19+
20+interface
21+
22+uses
23+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
24+ Menus;
25+
26+type
27+
28+ { TForm1 }
29+
30+ TForm1 = class(TForm)
31+ procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
32+ private
33+ public
34+ OriginalBounds: TRect;
35+ OriginalWindowState: TWindowState;
36+ ScreenBounds: TRect;
37+ procedure SwitchFullScreen;
38+ end;
39+
40+var
41+ Form1: TForm1;
42+
43+implementation
44+
45+{$R *.lfm}
46+
47+{ TForm1 }
48+
49+procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
50+ );
51+const
52+ KeyF11 = 122;
53+begin
54+ if Key = KeyF11 then SwitchFullScreen;
55+end;
56+
57+procedure TForm1.SwitchFullScreen;
58+begin
59+ if BorderStyle <> bsNone then begin
60+ // To full screen
61+ OriginalWindowState := WindowState;
62+ OriginalBounds := BoundsRect;
63+
64+ BorderStyle := bsNone;
65+ ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect;
66+ with ScreenBounds do
67+ SetBounds(Left, Top, Right - Left, Bottom - Top) ;
68+ end else begin
69+ // From full screen
70+ {$IFDEF MSWINDOWS}
71+ BorderStyle := bsSizeable;
72+ {$ENDIF}
73+ if OriginalWindowState = wsMaximized then
74+ WindowState := wsMaximized
75+ else
76+ with OriginalBounds do
77+ SetBounds(Left, Top, Right - Left, Bottom - Top) ;
78+ {$IFDEF LINUX}
79+ BorderStyle := bsSizeable;
80+ {$ENDIF}
81+ end;
82+end;
83+
84+end.
85+```
86+
87+## Obtenir la taille de la barre de tâche
88+
89+Si vous voulez garder la barre de tâches visible, vous devez ajuster la taille en fonction de la position et de la taille de la barre de tâche.
90+
91+*Pour Windows:*
92+
93+``` pascal
94+function GetTaskBarSize: TRect;
95+begin
96+ SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
97+end;
98+```
99+
100+## Façon GTK de passer en mode plein écran
101+
102+Pour passr la fiche dans les dimensions plein écran:
103+
104+``` pascal
105+gdk_window_fullscreen(PGtkWidget(Handle)^.window);
106+```
107+
108+Pour revenir au mode normal:
109+
110+``` pascal
111+gdk_window_unfullscreen(PGtkWidget(Handle)^.window);
112+```
113+
114+C'est uniquement pour GTK2. Vous devez ajouter à la section uses des unités tels que gtk2, gdk2, glib2.Vous pouvez le faire avec la directive {\$IFDEF LCLGTK2}, gtk2, gdk2, glib2{\$ENDIF}.
115+
116+## Changer la résolution de l'écran
117+
118+Actuellement, il n'y a pas de manière indépendante de l'OS pour basculer la résolution de l'écran.
119+
120+Pour Windows, vous pouvez trouver des informations dans l'article pour Delphi [Get and Set Screen Resolution (Display Device Modes)](http://delphi.about.com/od/graphics/a/change_display.htm)
121+
122+## Voir aussi
123+
124+- [[WinCE Programming Tips|WinCE Programming Tips - Making a Fullscreen Application]]
125+
126+## Liens externes
127+
128+- [Run Your Delphi Application in Full Screen - Implement "F11 - Full Screen"](http://delphi.about.com/od/delphitips2010/qt/delphi-application-full-screen-mode-f11.htm)
129+- [Very simple way to make your form Fullscreen & Restore (LazPlanet)](http://lazplanet.blogspot.com/2014/02/make-your-form-fullscreen.html)
130+
131+---
132+*From the Free Pascal wiki, page "Application full screen mode/fr", as it stood on 2020-02-09 after a change by GAN, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
133+Category: Lazarus/fr
134+Category: Tutorials/fr

Back to history