Sign in Join
Wiki copytemporary

Application full screen mode/fr: what changed

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

OldNewLine
11## Introduction
22
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.
3+Quelques applications telles des fouineurs Web permettent de montrer en mode plein écran en utilisant la touche `F11`. 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.
44
55Pour être capable de passer en mode plein écran, vous aurez besoin:
66
77- de mémoriser l'état antérieur de la fiche tel que la position, la taille et l'état de la fenêtre
88- d'être capable de déterminer la taille de l'écran
99- de capturer quelque touche et d'effectuer l'opération
1010
1111La 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.
1212
1313## Programme d'exemple
1414
1515``` pascal
1616unit Unit1;
1717
1818{$mode objfpc}{$H+}
1919
2020interface
2121
2222uses
2323 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
2424 Menus;
2525
2626type
2727
2828 { TForm1 }
2929
3030 TForm1 = class(TForm)
3131 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
3232 private
3333 public
3434 OriginalBounds: TRect;
3535 OriginalWindowState: TWindowState;
3636 ScreenBounds: TRect;
3737 procedure SwitchFullScreen;
3838 end;
3939
4040var
4141 Form1: TForm1;
4242
4343implementation
4444
4545{$R *.lfm}
4646
4747{ TForm1 }
4848
4949procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
5050 );
5151const
5252 KeyF11 = 122;
5353begin
5454 if Key = KeyF11 then SwitchFullScreen;
5555end;
5656
5757procedure TForm1.SwitchFullScreen;
5858begin
5959 if BorderStyle <> bsNone then begin
6060 // To full screen
6161 OriginalWindowState := WindowState;
6262 OriginalBounds := BoundsRect;
6363
6464 BorderStyle := bsNone;
6565 ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect;
6666 with ScreenBounds do
6767 SetBounds(Left, Top, Right - Left, Bottom - Top) ;
6868 end else begin
6969 // From full screen
7070 {$IFDEF MSWINDOWS}
7171 BorderStyle := bsSizeable;
7272 {$ENDIF}
7373 if OriginalWindowState = wsMaximized then
7474 WindowState := wsMaximized
7575 else
7676 with OriginalBounds do
7777 SetBounds(Left, Top, Right - Left, Bottom - Top) ;
7878 {$IFDEF LINUX}
7979 BorderStyle := bsSizeable;
8080 {$ENDIF}
8181 end;
8282end;
8383
8484end.
8585```
8686
8787## Obtenir la taille de la barre de tâche
8888
8989Si 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.
9090
9191*Pour Windows:*
9292
9393``` pascal
9494function GetTaskBarSize: TRect;
9595begin
9696 SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
9797end;
9898```
9999
100100## Façon GTK de passer en mode plein écran
101101
102102Pour passr la fiche dans les dimensions plein écran:
103103
104104``` pascal
105105gdk_window_fullscreen(PGtkWidget(Handle)^.window);
106106```
107107
108108Pour revenir au mode normal:
109109
110110``` pascal
111111gdk_window_unfullscreen(PGtkWidget(Handle)^.window);
112112```
113113
114114C'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}.
115115
116116## Changer la résolution de l'écran
117117
118118Actuellement, il n'y a pas de manière indépendante de l'OS pour basculer la résolution de l'écran.
119119
120120Pour 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)
121121
122122## Voir aussi
123123
124124- [[WinCE Programming Tips|WinCE Programming Tips - Making a Fullscreen Application]]
125125
126126## Liens externes
127127
128128- [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)
129129- [Very simple way to make your form Fullscreen & Restore (LazPlanet)](http://lazplanet.blogspot.com/2014/02/make-your-form-fullscreen.html)
130130
131131---
132132*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).*
133133Category: Lazarus/fr
134134Category: Tutorials/fr

Back to history