| 是停在屏幕,
//位置由SetWindowPlacement来决定
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle,GWL_EXSTYLE ,WS_EX_TOOLWINDOW);
GetWindowPlacement(Application.Handle,@placement);
placement.flags:=WPF_SETMINPOSITION;
placement.ptMinPosition.x:=1050;
placement.ptMinPosition.y:=800;
SetWindowPlacement(Application.Handle,@placement);
SetTray(NIM_ADD );
end;
end;
end;
procedure TMyTray.SetIcon(Value:TIcon);
begin
FIcon.Assign(Value);
FsetDfIcon:=False; //有了自定义的图标,则默认图标自动设为False
if FIcon.Empty then
FsetDfIcon:=True;
if (isMin)and(Factive) then
SetTray(NIM_MODIFY );
end;
//设置是否为默认图标,与FIcon为互相的变量,只能有其中一个
procedure TMyTray.SetDfIcon(Value:Boolean);
begin
if FSetDfIcon<>Value then
begin
FSetDfIcon:=Value;
if not FSetDfIcon then
begin
if FIcon.Empty then begin
FSetDfIcon:=True;
exit;
end;
end
else begin
if (IsMin)and(FActive) then
SetTray(NIM_MODIFY);
end;
end;
end;
procedure TMyTray.SetActive(Value:Boolean);
begin
if FActive<>Value then
begin
FActive:=Value;
end;
end;
procedure TMyTray.SetHint(Value:String);
begin
if FHint<>Value then
begin
FHInt:=Value;
if (IsMin)and(FActive) then
SetTray(NIM_MODIFY);
end;
end;
procedure TMyTray.SetRMode(Value:TRMode);
begin
if FRmode<>Value then
FRmode:=Value;
end;
//设置托盘方式,显示,修改,删掉,重要方法
procedure TMyTray.SetTray(Way:DWORD);
begin
FIconData.cbSize:=Sizeof(FIconData);
FIconData.Wnd:=FHandle;
FIConData.uID:=0;
FIConData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
FIConData.uCallbackMessage:=WM_TrayMsg;
FIConData.hIcon:=GetActiveIcon;
StrLCopy(FIConData.szTip,Pchar(FHint),63);
Shell_NotifyIcon(Way,@FIconData);
end;
//取得可用的图标
function TMyTray.GetActiveIcon:THandle;
begin
if not FSetDfIcon then 上一页 [1] [2] [3] [4] [5] [6] [7] 下一页 |