使用SetWindowLong去掉窗口标题和边框,
然后设置窗口位置为全屏幕,此时任务栏会自动隐藏
看下列代码
const
tsFlag=SWP_DRAWFRAME or SWP_FRAMECHANGED or SWP_NOZORDER or SWP_NOMOVE or SWP_NOSIZE;
tnFlag=SWP_DRAWFRAME or SWP_FRAMECHANGED;
procedure TMain.mFullScreenClick(Sender: TObject);
begin
if mFullScreen.Checked then
begin
LockWindowUpdate(Handle);
St_top.Visible:=false;
CoolBar1.Visible:=false;
Stb.Visible:=false;
ShowMenus(false);
SavWL1:=GetWindowLong(Handle,GWL_STYLE);
SavWL2:=GetWindowLong(Panel1.Handle,GWL_EXSTYLE);
SvLeft:=Left;
SvTop:=Top;
SvWidth:=Width;
SvHeight:=Height;
SetWindowLong(Panel1.Handle,GWL_EXSTYLE,SavWL2 and not WS_EX_CLIENTEDGE);
SetWindowPos(Panel1.Handle,0,0,0,0,0,tsFlag);
SetWindowLong(Handle,GWL_STYLE,Integer(WS_POPUP or WS_VISIBLE));
SetWindowPos(Handle,HWND_TOP,0,0,Screen.Width,Screen.Height,tnFlag);
LockWindowUpdate(0);
end else
begin
LockWindowUpdate(Handle);
SetWindowLong(Panel1.Handle,GWL_EXSTYLE,SavWL2);
SetWindowPos(Panel1.Handle,0,0,0,0,0,tsFlag);
CoolBar1.Visible:=N9.Checked;
Stb.Visible:=N10.Checked;
St_top.Visible:=N9.Checked;
ShowMenus(true);
SetWindowLong(Handle,GWL_STYLE,SavWL1);
SetWindowPos(Handle,HWND_NOTOPMOST,SvLeft,SvTop,SvWidth,SvHeight,tnFlag);
LockWindowUpdate(0);
end;
end;