Leonardozwei
Programmer
- Jun 24, 2002
- 15
I want to make an Application, that send to the windows-IconTaskBar when it the window is minimized.
with the function
procedure TForm1.IconTaskBar_show(Icon:TIcon; Hint:string);
var vIconTaskBar : TNotifyIconData;
begin
Hint := copy(Hint, 1, 63); // maximum size of the hint-field
With vIconTaskBar do
begin
cbSize:=SizeOf(vIconTaskBar);
Wnd:=Handle;
uID:= 1; // we use only one Icon in the Taskbar
uFlags:= NIF_ICON Or NIF_MESSAGE Or NIF_TIP;
uCallbackMessage:=WM_IconTaskBar_Notify; // Message-ID sended to notify Icon-events
hIcon:=Icon.Handle; // The Icon to Show
StrPCopy(szTip, Hint);
end;
Shell_NotifyIcon(NIM_ADD, @vIconTaskBar);
FIconTaskBar_Visible := true;
end;
it is Called like this
IconTaskBar_show(Application.Icon, 'ISDN-View');
Hide; // hide the Main-Form
this works so far, but now I want to exchange the Icon with another... this function should do this...
procedure TForm1.IconTaskBar_Modify(NewIcon:TIcon; Hint:string);
var vIconTaskBar : TNotifyIconData;
begin
Hint := copy(Hint, 1, 63); // maximum size of the hint-field
With vIconTaskBar do
begin
cbSize:=SizeOf(vIconTaskBar);
Wnd:=Handle;
uID:= 1; // we use only one Icon in the Taskbar
uFlags:= NIF_ICON Or NIF_TIP;
uCallbackMessage:=WM_IconTaskBar_Notify; // Message-ID sended to notify Icon-events
hIcon:=Icon.Handle; // The Icon to Show
StrPCopy(szTip, Hint);
end;
Shell_NotifyIcon(NIM_MODIFY, @vIconTaskBar);
end;
it is called like this
if Icons[B1, B2] = nil then
begin
Icons[B1, B2] := TIcon.Create;
try
Icons[B1, B2].LoadFromFile(fn);
finally
end;
end;
Application.Icon := Icons[B1, B2];
IconTaskBar_Modify(Icons[B1, B2], 'ISDN-View');
B1 and B2 are the the differnt states, that the Tray-Icon should visulized.
Now the Problem:
When the Icon should change, it simply disapear, or better the Place where the icon should bee is empty. When I click on the Empty place in the Icon-Tray it sends Notification-Messages to my aplication, so it is still there, but with no image.
what's wrong? Can anybody help me?
Leonardo
with the function
procedure TForm1.IconTaskBar_show(Icon:TIcon; Hint:string);
var vIconTaskBar : TNotifyIconData;
begin
Hint := copy(Hint, 1, 63); // maximum size of the hint-field
With vIconTaskBar do
begin
cbSize:=SizeOf(vIconTaskBar);
Wnd:=Handle;
uID:= 1; // we use only one Icon in the Taskbar
uFlags:= NIF_ICON Or NIF_MESSAGE Or NIF_TIP;
uCallbackMessage:=WM_IconTaskBar_Notify; // Message-ID sended to notify Icon-events
hIcon:=Icon.Handle; // The Icon to Show
StrPCopy(szTip, Hint);
end;
Shell_NotifyIcon(NIM_ADD, @vIconTaskBar);
FIconTaskBar_Visible := true;
end;
it is Called like this
IconTaskBar_show(Application.Icon, 'ISDN-View');
Hide; // hide the Main-Form
this works so far, but now I want to exchange the Icon with another... this function should do this...
procedure TForm1.IconTaskBar_Modify(NewIcon:TIcon; Hint:string);
var vIconTaskBar : TNotifyIconData;
begin
Hint := copy(Hint, 1, 63); // maximum size of the hint-field
With vIconTaskBar do
begin
cbSize:=SizeOf(vIconTaskBar);
Wnd:=Handle;
uID:= 1; // we use only one Icon in the Taskbar
uFlags:= NIF_ICON Or NIF_TIP;
uCallbackMessage:=WM_IconTaskBar_Notify; // Message-ID sended to notify Icon-events
hIcon:=Icon.Handle; // The Icon to Show
StrPCopy(szTip, Hint);
end;
Shell_NotifyIcon(NIM_MODIFY, @vIconTaskBar);
end;
it is called like this
if Icons[B1, B2] = nil then
begin
Icons[B1, B2] := TIcon.Create;
try
Icons[B1, B2].LoadFromFile(fn);
finally
end;
end;
Application.Icon := Icons[B1, B2];
IconTaskBar_Modify(Icons[B1, B2], 'ISDN-View');
B1 and B2 are the the differnt states, that the Tray-Icon should visulized.
Now the Problem:
When the Icon should change, it simply disapear, or better the Place where the icon should bee is empty. When I click on the Empty place in the Icon-Tray it sends Notification-Messages to my aplication, so it is still there, but with no image.
what's wrong? Can anybody help me?
Leonardo