/// <summary> /// Creates a default data structure that provides a hidden taskbar icon without the icon being set. /// </summary> /// <param name="handle">The handle.</param> /// <returns>The icon data.</returns> public static NotifyIconData CreateDefault(IntPtr handle) { var data = new NotifyIconData(); if (Environment.OSVersion.Version.Major >= 6) { // use the current size data.Size = (uint)Marshal.SizeOf(data); } else { // we need to set another size on xp/2003- otherwise certain // features (e.g. balloon tooltips) don't work. data.Size = 504; // set to fixed timeout data.VersionOrTimeout = 10; } data.WindowHandle = handle; data.TaskbarIconId = 0x0; data.CallbackMessageId = WindowMessageSink.CallbackMessageId; data.VersionOrTimeout = (uint)NotifyIconVersion.Win95; data.IconHandle = IntPtr.Zero; // hide initially data.NotifyIconState = IconState.Hidden; data.StateMask = IconState.Hidden; // set flags data.ValidMembers = IconDataMembers.Message | IconDataMembers.Icon | IconDataMembers.Tip; // reset strings data.ToolTipText = data.BalloonText = data.BalloonTitle = string.Empty; return(data); }
public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In] ref NotifyIconData data);