Application full screen mode/fr: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | ## Introduction | |
| 2 | 2 | ||
| 3 | - | ||
| 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. | |
| 4 | 4 | ||
| 5 | 5 | Pour être capable de passer en mode plein écran, vous aurez besoin: | |
| 6 | 6 | ||
| 7 | 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 | 8 | - d'être capable de déterminer la taille de l'écran | |
| 9 | 9 | - de capturer quelque touche et d'effectuer l'opération | |
| 10 | 10 | ||
| 11 | 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 | 12 | ||
| 13 | 13 | ## Programme d'exemple | |
| 14 | 14 | ||
| 15 | 15 | ``` pascal | |
| 16 | 16 | unit Unit1; | |
| 17 | 17 | ||
| 18 | 18 | {$mode objfpc}{$H+} | |
| 19 | 19 | ||
| 20 | 20 | interface | |
| 21 | 21 | ||
| 22 | 22 | uses | |
| 23 | 23 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, | |
| 24 | 24 | Menus; | |
| 25 | 25 | ||
| 26 | 26 | type | |
| 27 | 27 | ||
| 28 | 28 | { TForm1 } | |
| 29 | 29 | ||
| 30 | 30 | TForm1 = class(TForm) | |
| 31 | 31 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); | |
| 32 | 32 | private | |
| 33 | 33 | public | |
| 34 | 34 | OriginalBounds: TRect; | |
| 35 | 35 | OriginalWindowState: TWindowState; | |
| 36 | 36 | ScreenBounds: TRect; | |
| 37 | 37 | procedure SwitchFullScreen; | |
| 38 | 38 | end; | |
| 39 | 39 | ||
| 40 | 40 | var | |
| 41 | 41 | Form1: TForm1; | |
| 42 | 42 | ||
| 43 | 43 | implementation | |
| 44 | 44 | ||
| 45 | 45 | {$R *.lfm} | |
| 46 | 46 | ||
| 47 | 47 | { TForm1 } | |
| 48 | 48 | ||
| 49 | 49 | procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState | |
| 50 | 50 | ); | |
| 51 | 51 | const | |
| 52 | 52 | KeyF11 = 122; | |
| 53 | 53 | begin | |
| 54 | 54 | if Key = KeyF11 then SwitchFullScreen; | |
| 55 | 55 | end; | |
| 56 | 56 | ||
| 57 | 57 | procedure TForm1.SwitchFullScreen; | |
| 58 | 58 | begin | |
| 59 | 59 | if BorderStyle <> bsNone then begin | |
| 60 | 60 | // To full screen | |
| 61 | 61 | OriginalWindowState := WindowState; | |
| 62 | 62 | OriginalBounds := BoundsRect; | |
| 63 | 63 | ||
| 64 | 64 | BorderStyle := bsNone; | |
| 65 | 65 | ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect; | |
| 66 | 66 | with ScreenBounds do | |
| 67 | 67 | SetBounds(Left, Top, Right - Left, Bottom - Top) ; | |
| 68 | 68 | end else begin | |
| 69 | 69 | // From full screen | |
| 70 | 70 | {$IFDEF MSWINDOWS} | |
| 71 | 71 | BorderStyle := bsSizeable; | |
| 72 | 72 | {$ENDIF} | |
| 73 | 73 | if OriginalWindowState = wsMaximized then | |
| 74 | 74 | WindowState := wsMaximized | |
| 75 | 75 | else | |
| 76 | 76 | with OriginalBounds do | |
| 77 | 77 | SetBounds(Left, Top, Right - Left, Bottom - Top) ; | |
| 78 | 78 | {$IFDEF LINUX} | |
| 79 | 79 | BorderStyle := bsSizeable; | |
| 80 | 80 | {$ENDIF} | |
| 81 | 81 | end; | |
| 82 | 82 | end; | |
| 83 | 83 | ||
| 84 | 84 | end. | |
| 85 | 85 | ``` | |
| 86 | 86 | ||
| 87 | 87 | ## Obtenir la taille de la barre de tâche | |
| 88 | 88 | ||
| 89 | 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 | 90 | ||
| 91 | 91 | *Pour Windows:* | |
| 92 | 92 | ||
| 93 | 93 | ``` pascal | |
| 94 | 94 | function GetTaskBarSize: TRect; | |
| 95 | 95 | begin | |
| 96 | 96 | SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0); | |
| 97 | 97 | end; | |
| 98 | 98 | ``` | |
| 99 | 99 | ||
| 100 | 100 | ## Façon GTK de passer en mode plein écran | |
| 101 | 101 | ||
| 102 | 102 | Pour passr la fiche dans les dimensions plein écran: | |
| 103 | 103 | ||
| 104 | 104 | ``` pascal | |
| 105 | 105 | gdk_window_fullscreen(PGtkWidget(Handle)^.window); | |
| 106 | 106 | ``` | |
| 107 | 107 | ||
| 108 | 108 | Pour revenir au mode normal: | |
| 109 | 109 | ||
| 110 | 110 | ``` pascal | |
| 111 | 111 | gdk_window_unfullscreen(PGtkWidget(Handle)^.window); | |
| 112 | 112 | ``` | |
| 113 | 113 | ||
| 114 | 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 | 115 | ||
| 116 | 116 | ## Changer la résolution de l'écran | |
| 117 | 117 | ||
| 118 | 118 | Actuellement, il n'y a pas de manière indépendante de l'OS pour basculer la résolution de l'écran. | |
| 119 | 119 | ||
| 120 | 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 | 121 | ||
| 122 | 122 | ## Voir aussi | |
| 123 | 123 | ||
| 124 | 124 | - [[WinCE Programming Tips|WinCE Programming Tips - Making a Fullscreen Application]] | |
| 125 | 125 | ||
| 126 | 126 | ## Liens externes | |
| 127 | 127 | ||
| 128 | 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 | 129 | - [Very simple way to make your form Fullscreen & Restore (LazPlanet)](http://lazplanet.blogspot.com/2014/02/make-your-form-fullscreen.html) | |
| 130 | 130 | ||
| 131 | 131 | --- | |
| 132 | 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 | 133 | Category: Lazarus/fr | |
| 134 | 134 | Category: Tutorials/fr |
