procedure TForm1.FormCreate(Sender: TObject); begin SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION); end;
我自己用的函数procedure HideTitleBar(IsHide: Boolean; frm: TForm); var lStyle: Integer; r: TRect; begin GetWindowRect(frm.Handle, r); lStyle := GetWindowLong(frm.Handle, GWL_STYLE); if IsHide then begin lStyle := lStyle and not WS_SYSMENU; lStyle := lStyle and not WS_CAPTION; end else begin lStyle := lStyle or WS_SYSMENU; lStyle := lStyle or WS_CAPTION; end; SetWindowLong(frm.Handle, GWL_STYLE, lStyle); SetWindowPos( frm.Handle, 0, r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top, SWP_NOREPOSITION or SWP_NOZORDER or SWP_FRAMECHANGED ); end;
begin
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);
end;
var
lStyle: Integer;
r: TRect;
begin
GetWindowRect(frm.Handle, r);
lStyle := GetWindowLong(frm.Handle, GWL_STYLE);
if IsHide then
begin
lStyle := lStyle and not WS_SYSMENU;
lStyle := lStyle and not WS_CAPTION;
end
else begin
lStyle := lStyle or WS_SYSMENU;
lStyle := lStyle or WS_CAPTION;
end;
SetWindowLong(frm.Handle, GWL_STYLE, lStyle);
SetWindowPos(
frm.Handle,
0,
r.Left,
r.Top,
r.Right - r.Left,
r.Bottom - r.Top,
SWP_NOREPOSITION or SWP_NOZORDER or SWP_FRAMECHANGED
);
end;