[SOLVED]Some problems about wsFullScreen lazarus / 31-LCL ---------------------------------------------------------------------- tomitomy · 2017-10-11 12:18 Hi, i have encountered some problems while running the following code, the result is not what i want. ------------------------------------------------------------ OS: Linux Mint 18.2 MATE-64Bit Lazarus: 1.8.0 RC4 (FPC 3.0.4) Code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);begin  if WindowState = wsFullScreen then    WindowState := wsNormal  else    WindowState := wsFullScreen;end; Running result: Code: [Select]Press Key         WindowState 1 times           wsFullScreen 2 times           wsFullScreen 3 times           wsNormal 4 times           wsFullScreen 5 times           wsFullScreen 6 times           wsNormal ------------------------------------------------------------ OS: Windows 7-64Bit Lazarus: 1.6.4 (FPC 3.0.2) The same code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);begin  if WindowState = wsFullScreen then    WindowState := wsNormal  else    WindowState := wsFullScreen;end; Running result: Code: [Select]Press Key         WindowState 1 times           wsMaximized 2 times           wsMaximized 3 times           wsNormal 4 times           wsMaximized 5 times           wsMaximized 6 times           wsNormal ------------------------------------------------------------ I want the window to switch between wsFullScreen and wsNormal, but the result is not, is this a issue? ---------------------------------------------------------------------- ASerge · 2017-10-11 21:09 I will say only for Windows. In Windows, there is no FullScreen status, only Maximized. Lazarus passes this value in both cases. As a result: 1. WindowState := wsFullScreen   ShowWindow(SW_SHOWMAXIMIZED).   System message WM_SIZE.   Form proc Resizing.   WindowState := wsMaximized. 2. WindowState := wsFullScreen   ShowWindow(SW_SHOWMAXIMIZED). 3. WindowsState := wsNormal   ShowWindow(SW_SHOWNORMAL).   System message WM_SIZE.   Form proc Resizing.   WindowState := wsNormal Test: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function WindowStateToStr(State: TWindowState): string;const  CText: array [TWindowState] of string = (    'wsNormal', 'wsMinimized', 'wsMaximized', 'wsFullScreen');begin  Result := CText[State];end; procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);begin  if WindowState = wsFullScreen then    WindowState := wsNormal  else    WindowState := wsFullScreen;  Caption := 'After key press: ' + WindowStateToStr(WindowState);end; ---------------------------------------------------------------------- tomitomy · 2017-10-12 05:35 Quote from: ASerge on October 11, 2017, 11:09:25 pmI will say only for Windows. Thank you for your explanation, I have understood. I can use the following code in windows system, but it does not work properly in Linux mint, is there any way to work properly in Linux? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TForm1 = class(TForm)    procedure FormKeyPress(Sender: TObject; var Key: char);  private    SavedBorderStyle: TBorderStyle;    SavedLeft, SavedTop, SavedWidth, SavedHeight: Integer;  public           procedure ToggleFullScreen;  end; procedure TForm1.ToggleFullScreen;begin  if BorderStyle <> bsNone then  begin  // Save Form Size    SavedBorderStyle := BorderStyle;    SavedLeft := Left;    SavedTop := Top;    SavedWidth := Width;    SavedHeight := Height;    // FullScreen    BorderStyle := bsNone;    Left := -1;    Top := -1;    Width := Screen.Width + 2;    Height := Screen.Height + 2;  end  else  begin    // Restore Form Size    BorderStyle := SavedBorderStyle;    Left := SavedLeft;    Top := SavedTop;    Width := SavedWidth;    Height := SavedHeight;  end;end; procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);begin  ToggleFullScreen;end; ---------------------------------------------------------------------- ASerge · 2017-10-12 14:11 Usually the windows do not open so wide Here is the code shorter and without errors (BorderStyle: TFormBorderStyle but not TBorderStyle) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TForm1 = class(TForm)    procedure FormKeyPress(Sender: TObject; var Key: char);  private    FOldBorderStyle: TFormBorderStyle;    FOldBoundsRect: TRect;    procedure ToggleFullScreen;  end; procedure TForm1.ToggleFullScreen;begin  if BorderStyle <> bsNone then  begin  FOldBoundsRect := BoundsRect;    FOldBorderStyle := BorderStyle;    BorderStyle := bsNone;    BoundsRect := Screen.DesktopRect;  end  else  begin    BorderStyle := FOldBorderStyle;    BoundsRect := FOldBoundsRect;  end;end; procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);begin  ToggleFullScreen;end; ---------------------------------------------------------------------- tomitomy · 2017-10-13 05:28 Quote from: ASerge on October 12, 2017, 04:11:19 pmUsually the windows do not open so wide Here is the code shorter and without errors (BorderStyle: TFormBorderStyle but not TBorderStyle) I like your code, your code is clear and rigorous, thank you very much. This code in the Windows can work very well, but the performance of the Linux is very strange, some people know how to achieve full-screen switch in Linux? Thank you in advance! ---------------------------------------------------------------------- tomitomy · 2017-10-13 06:47 I thought of a way to achieve full-screen switch under Windows and Linux, and I can not find a better way. If anyone has a better way, please tell me, thanks in advance! This's my way: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    FOldBorderStyle: TFormBorderStyle;    FOldBoundsRect: TRect;  public  end; procedure TForm1.Button1Click(Sender: TObject);var  Form: TForm;begin  if BorderStyle = bsNone then begin    BorderStyle := FOldBorderStyle;    BoundsRect := FOldBoundsRect;  end else begin    FOldBorderStyle := BorderStyle;    FOldBoundsRect := BoundsRect;    BorderStyle := bsNone;    BoundsRect := Screen.DesktopRect;    // In Linux, need a form to assist    Form := TForm.Create(nil);    try      Parent := Form;      Parent := nil    finally      Form.Free;    end;  end;end;