如何动态隐藏(显示)窗口的标题栏?(100分)

  • 主题发起人 主题发起人 jingtao
  • 开始时间 开始时间
J

jingtao

Unregistered / Unconfirmed
GUEST, unregistred user!
如何动态隐藏(显示)窗口的标题栏?(要源程序)
 
procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and (not WS_CAPTION));<br>&nbsp; Height:=ClientHeight;<br>&nbsp; Width:=ClientWidth;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) or (WS_CAPTION));<br>&nbsp; Height:=ClientHeight;<br>&nbsp; Width:=ClientWidth;<br>end;<br>
 
//再来一个完整的程序,呵呵。。。。<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and (not WS_CAPTION));<br>&nbsp; ClientHeight:=Height;<br>&nbsp; ClientWidth:=Width;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) or (WS_CAPTION));<br>&nbsp; Height:=ClientHeight;<br>&nbsp; Width:=ClientWidth;<br>end;<br><br>end.<br>
 
动态改变BorderStyle即可达到隐藏标题兰的目的, BorderStyle := bsNone不显示标题. 下面的例子可以显示/隐藏标题兰:<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; if BorderStyle = bsNone then<br>&nbsp; &nbsp; BorderStyle := bsSizeable<br>&nbsp; else<br>&nbsp; &nbsp; BorderStyle := bsNone;<br>end;
 
BorderStyle := bsNone;//窗体没有3D效果
 
http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=197366
 
多人接受答案了。
 
后退
顶部