设置TrayIcon的Visible时抛异常,求解

iqyely 2010-07-09 10:31:56
在程序的退出事件FormClose中加了TrayIcon.Visible := False;

在部分机器上抛出了EOutOfResources Cannot remove shell notification icon.异常

查看了下TrayIcon对应的源码

procedure TCustomTrayIcon.SetVisible(Value: Boolean);
begin
if FVisible <> Value then
begin
FVisible := Value;
if (not FAnimate) or (FAnimate and FCurrentIcon.Empty) then
SetDefaultIcon;

if not (csDesigning in ComponentState) then
begin
if FVisible then
Refresh(NIM_ADD)
else if not (csLoading in ComponentState) then
begin
if not Refresh(NIM_DELETE) then
raise EOutOfResources.Create(STrayIconRemoveError);
end;
if FAnimate then
FTimer.Enabled := Value;
end;
end;
end;


源码中有一处的确抛出了此异常,想请教下,这个异常何时触发的?如何解决这个问题啊?请大家帮忙看看,谢谢。
...全文
166 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yudechibang88 2010-07-09
  • 打赏
  • 举报
回复
用RzTrayIcon就不会存在这个问题了。
金卯刀 2010-07-09
  • 打赏
  • 举报
回复
你看看Refresh(NIM_DELETE)就知道了
iqyely 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ljmanage 的回复:]
FormClose中。你应该删除这个TrayICON,才不会抛出这个异常
[/Quote]

直接调用TrayIcon.Free; ?

在我自己的机子上还没报过这样的异常。
李_军 2010-07-09
  • 打赏
  • 举报
回复
FormClose中。你应该删除这个TrayICON,才不会抛出这个异常

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧