Recent

Author Topic: [SOLVED] Fullscreen  (Read 1000 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 573
[SOLVED] Fullscreen
« on: September 22, 2023, 12:43:25 pm »
Hello forum members
I came up with code that supports full screen, but does not cover the entire screen. How can I improve the code?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. const
  3.   Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
  4.   FullScreen: Boolean = False;
  5. begin
  6.   FullScreen := not FullScreen;
  7.   If FullScreen Then Begin
  8.     Rect := BoundsRect;
  9.     SetBounds(
  10.       Left - ClientOrigin.X,
  11.       Top - ClientOrigin.Y,
  12.       GetDeviceCaps( Canvas.handle, HORZRES ) + (screen.Width - ClientWidth),
  13.       GetDeviceCaps( Canvas.handle, VERTRES ) + (screen.Height - ClientHeight));
  14.   SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
  15.   End Else
  16.   begin
  17.       SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
  18.     BoundsRect := Rect;
  19.   end;
  20. end;
  21.  
« Last Edit: September 23, 2023, 07:32:47 pm by Pe3s »

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Fullscreen
« Reply #1 on: September 22, 2023, 12:50:20 pm »
not tried or tested, but have you seen the wiki

https://wiki.lazarus.freepascal.org/Application_full_screen_mode
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Pe3s

  • Hero Member
  • *****
  • Posts: 573
Re: Fullscreen
« Reply #2 on: September 22, 2023, 01:19:55 pm »
@Josh, I've read the wiki, the problem is that I can't use WindowState or border style


Pe3s

  • Hero Member
  • *****
  • Posts: 573
Re: Fullscreen
« Reply #3 on: September 23, 2023, 07:32:33 pm »
Thank you  :)

 

TinyPortal © 2005-2018