用Delphi怎么实现QQ的消息提示

2025-06-23 00:44:04
推荐回答(1个)
回答1:

1.新建工程并在FORM1中添加一个按钮
2.添加新窗体 并在Form2中添加SHOW过程 (覆盖原有的)
type
TForm2 = class(TForm)
procedure show(var Msg:string); //添加这行
private
.....
3.在implementation部分填写
procedure tform2.show(var Msg:string);
var
hApp :HWND;
rcApp:TRect;
RenG :integer;
begin
hApp := FindWindow('Shell_TrayWnd', '');

if hApp <> 0 then
GetWindowRect(hApp, rcApp);

Reng:= rcApp.Bottom-rcApp.Top; //得到任务栏高度

BorderStyle:=bsDialog;

//设置大小 你可以自己设置

Left:=screen.Width-width; //设置窗口的位置
Top :=screen.Height-Reng-height;

Visible:=true; //显示窗口

Canvas.TextOut(5,5,Msg);//窗口显示传进的字符串 用别的组建也可以

end;

4.回到UNIT1单元 双击刚才FORM1上的按钮并填写
//声明 这个
var
n:string;
//begin下写
n:='Hiyali';
form2.show(n);

5.运行 按BUTTON1 看到效果
这里声明的N的值就是你所想提示的...(必需是变量)
UNIT2设计可以任意发挥