我是比較喜歡用MSN的,因為它的信息提示比較獨特,所有的聊天軟件都是彈出一個常規的Windows對話框,而它卻好像是從任務欄裡冒出來的。想想了,在Delphi這樣的純OOP工具裡加一個API應該不難實現,花了十來分鐘終於搞出來了,以下是實現方法:
1、建立一個APPLICATION,將兩個按鈕放置到主窗體FROM1中,分別為button1和button2。
button1.caption:=′打開窗口′;
button2.caption:=′關閉窗口′;
2、在file菜單項中的new中添加窗體form2,並且在project中的options裡,將form2設置為Available froms。
3、以下是FORM2窗體內的控件及屬性設置
form2.borderstyle:=bsNone;
添加panel1
panel1.align:=alclIEnt;
panel1.bevellnner:=bvLowered;
可以在panel1內添加你想要的文字。
OK,打開FORM2的代碼窗口,代碼如下:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
procedure Label1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private declarations }
public
procedure Show;
procedure close;
{ Public declarations }
end;
var
Form2: TForm2;
implementation
procedure tform2.close;
begin
if AnimateWindow(Handle,200,AW_VER_POSITIVE+AW_HIDE)=false then
begin
showmessage(′窗體退出出錯′);
free;
end;
inherited close;
end;
procedure tform2.Show;
begin
top:=430;
left:=560;
if AnimateWindow(Handle,200,AW_VER_NEGATIVE)=false then
begin
showmessage(′窗體顯示出錯′);
free;
end;
inherited show;
end;
{$R *.dfm}
以上紅色的區域為具體實現特效的代碼。為FORM1添加如下代碼即可:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
var
mesfrm:tform2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
mesfrm:=tform2.Create(application);
mesfrm.Show;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mesfrm.close;
end;
end.
OK,運行程序你已經可以看到效果了,不過記得將顯示器設為800*600象素呵。
由於制作時間較短,只實現了基本的效果,但稍加修改便可和MSN的信息提示一模一樣。