delphi窗体卷起来的小例子
用鼠标右键单击窗口的标题栏,可以自动把窗体卷起,再单击可以展开谁有这样的程序代码可以写出来么
答案:Delphi(Pascal) code
unit Unit1;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
procedure FormClick(Sender: TObject);
private
fOldClientHeight: Integer;
procedure WMNCRButtonDown(var Msg: TWMNCRButtonDown) ; message WM_NCRBUTTONDOWN;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMNCRButtonDown(var Msg: TWMNCRButtonDown) ;
var
h : integer;
begin
if (Msg.HitTest = HTCAPTION) then
begin
if (ClientHeight = 0) then
begin
for h := 0 to fOldClientHeight do ClientHeight := h;
Application.ProcessMessages;
end
else
begin
fOldClientHeight := ClientHeight;
for h := fOldClientHeight downto 0 do ClientHeight := h;
Application.ProcessMessages;
end;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
Close;
end;
end.