来源:www.cncfan.com | 2006-1-13 | (有1710人读过)
提示比较独特,所有的聊天软件都是弹出一个常规的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的信息提示一模一样。
|