Delphi:右下角任务栏的常驻与消息的弹出
💡 Delphi开发是我的爱好,积累各类的开发经验,分享给朋友们
这里可以采用trayicon组件来实现,不用其他的第三方插件,因为官方的基本上就够用了。
-
将组件添加到界面;
-
为了让form运行时,就显示图片,我们需要设置这么几点:
icon选项选择自己的icon图片;
visible选择为true,表示运行时,右下角图标就显示

3.为了显示相应的消息,写如下代码即可,着重是写下面的函数,在按钮中调用函数即可,运行效果如下图:

完成的程序代码:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, ShellAPI, RzTray, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
btn1: TRzBitBtn;
trycn1: TTrayIcon;
procedure btn1Click(Sender: TObject);
procedure ShowBalloonMessage(const Title, Msg: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
// 显示一个示例通知
ShowBalloonMessage('提示标题', '这是一个右下角气泡消息!');
end;
procedure TForm1.ShowBalloonMessage(const Title, Msg: string);
begin
if not trycn1.Visible then
trycn1.Visible := True;
trycn1.BalloonTitle := Title;
trycn1.BalloonHint := Msg;
trycn1.ShowBalloonHint;
end;
end.




留言
邮箱不会公开,留言经审核后显示。
还没有留言,来做第一个吧。