What is the best way to make a Delphi Application completely full screen?

前端 未结 9 1563
一生所求
一生所求 2020-12-07 23:07

What is the best way to make a delphi application (delphi 2007 for win32 here) go completely full screen, removing the application border and covering windows task bar ?

相关标签:
9条回答
  • 2020-12-08 00:06

    In my case, the only working solution is:

    procedure TFormHelper.FullScreenMode;
    begin
      BorderStyle := bsNone;
      ShowWindowAsync(Handle, SW_MAXIMIZE);
    end;
    
    0 讨论(0)
  • 2020-12-08 00:07

    Well, this has always worked for me. Seems a bit simpler...

    procedure TForm52.Button1Click(Sender: TObject);
    begin
      BorderStyle := bsNone;
      WindowState := wsMaximized;
    end;
    
    0 讨论(0)
  • 2020-12-08 00:07

    How to constrain a sub-form within the Mainform like it was an MDI app., but without the headaches! (Note: The replies on this page helped me get this working, so that's why I posted my solution here)

    private
    { Private declarations }
      StickyAt: Word;
      procedure WMWINDOWPOSCHANGING(Var Msg: TWMWINDOWPOSCHANGING); Message M_WINDOWPOSCHANGING;
      Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
    

    later...

        procedure TForm2.WMWINDOWPOSCHANGING(var Msg: TWMWINDOWPOSCHANGING);
        var
          A, B: Integer;
          iFrameSize: Integer;
          iCaptionHeight: Integer;
          iMenuHeight: Integer;
        begin
    
          iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);
          iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);
          iMenuHeight := GetSystemMetrics(SM_CYMENU);
    
          // inside the Mainform client area
          A := Application.MainForm.Left + iFrameSize;
          B := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight;
    
          with Msg.WindowPos^ do
          begin
    
            if x <= A + StickyAt then
              x := A;
    
            if x + cx >= A + Application.MainForm.ClientWidth - StickyAt then
              x := (A + Application.MainForm.ClientWidth) - cx + 1;
    
           if y <= B + StickyAt then
             y := B;
    
           if y + cy >= B + Application.MainForm.ClientHeight - StickyAt then
             y := (B + Application.MainForm.ClientHeight) - cy + 1;
    
          end;
    end;
    

    and yet more...

    Procedure TForm2.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);
    var
      iFrameSize: Integer;
      iCaptionHeight: Integer;
      iMenuHeight: Integer;
    Begin
      inherited;
      iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);
      iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);
      iMenuHeight := GetSystemMetrics(SM_CYMENU);
      With msg.MinMaxInfo^.ptMaxPosition Do
      begin
        // position of top when maximised
        X := Application.MainForm.Left + iFrameSize + 1;
        Y := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight + 1;
      end;
      With msg.MinMaxInfo^.ptMaxSize Do
      Begin
         // width and height when maximized
         X := Application.MainForm.ClientWidth;
         Y := Application.MainForm.ClientHeight;
      End;
      With msg.MinMaxInfo^.ptMaxTrackSize Do
      Begin
         // maximum size when maximised
         X := Application.MainForm.ClientWidth;
         Y := Application.MainForm.ClientHeight;
      End;
      // to do: minimum size (maybe)
    End;
    
    0 讨论(0)
提交回复
热议问题