delphi全屏显示form的两种方法

delphi8年前 (2017)发布 admin
553 0

方法一

procedure TfrmMainForm.FormCreate(Sender: TObject);   
begin   
  { Position form }   
  Top := 0 ;   
  Left := 0 ;   
  { Go full screen }   
  BorderStyle := bsNone ;   
  WindowState  := wsmaximized;   
  ClientWidth  := Screen.Width ;   
  ClientHeight := Screen.Height;   
  Refresh;   
  SetForegroundWindow(Handle) ;   
  SetActiveWindow(Application.Handle) ;   
end;   

方法二

{  
  Make your application Full Screen.  
  Disable all of the system keys.  
}   
procedure TForm1.FormCreate(Sender: TObject);   
var   
  HTaskbar: HWND;   
  OldVal: LongInt;   
begin   
  try   
    // Find handle of TASKBAR   
    HTaskBar := FindWindow('Shell_TrayWnd', nil);   
    // Turn SYSTEM KEYS off, Only Win 95/98/ME   
    SystemParametersInfo(97, Word(True), @OldVal, 0);   
    // Disable the taskbar   
    EnableWindow(HTaskBar, False);   
    // Hide the taskbar   
    ShowWindow(HTaskbar, SW_HIDE);   
  finally   
    with Form1 do    
    begin   
      BorderStyle := bsNone;   
      FormStyle   := fsStayOnTop;   
      Left        := 0;   
      Top         := 0;   
      Height      := Screen.Height;   
      Width       := Screen.Width;   
    end;   
  end   
end;   
  
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);   
var   
  HTaskbar: HWND;   
  OldVal: LongInt;   
begin   
  //Find handle of TASKBAR   
  HTaskBar := FindWindow('Shell_TrayWnd', nil);   
  //Turn SYSTEM KEYS Back ON, Only Win 95/98/ME   
  SystemParametersInfo(97, Word(False), @OldVal, 0);   
  //Enable the taskbar   
  EnableWindow(HTaskBar, True);   
  //Show the taskbar   
  ShowWindow(HTaskbar, SW_SHOW);   
end;  

转自http://blog.csdn.net/avan_lau/article/details/5533023

© 版权声明

相关文章