/// <summary> /// 关联到别的控件 /// </summary> /// <param name="control"></param> /// <param name="text"></param> public virtual void SetToolTip(Control control, string text) { bool bNewControl, bValidText; if (control == null) { throw new ArgumentNullException("control"); } bNewControl = !m_controls.ContainsKey(control); bValidText = (text != null && text.Length > 0); if (bNewControl) { if (bValidText) { ToolTipInfo info = new ToolTipInfo(text, "", ToolTipIconType.None); m_controls.Add(control, info); control.HandleCreated += new EventHandler(HandleCreated); control.HandleDestroyed += new EventHandler(HandleDestroyed); if (control.IsHandleCreated) { this.HandleCreated(control, EventArgs.Empty); } } } else { ToolTipInfo info = (ToolTipInfo)m_controls[control]; info.TipText = text; if (info.TipText.Length == 0 && info.TipTitle.Length == 0 && info.IconType == ToolTipIconType.None) { m_controls.Remove(control); control.HandleCreated -= new EventHandler(HandleCreated); control.HandleDestroyed -= new EventHandler(HandleDestroyed); if (m_addedList.Contains(control)) { DestroyRegion(control); m_addedList.Remove(control); } } } }
public void SetIconType(Control control, ToolTipIconType type) { bool bNewControl; if (control == null) { throw new ArgumentNullException("control"); } bNewControl = !m_controls.ContainsKey(control); if (bNewControl) { if (type != ToolTipIconType.None) { ToolTipInfo info = new ToolTipInfo("", "", type); m_controls.Add(control, info); control.HandleCreated += new EventHandler(HandleCreated); control.HandleDestroyed += new EventHandler(HandleDestroyed); if (control.IsHandleCreated) { this.HandleCreated(control, EventArgs.Empty); } } } else { ToolTipInfo info = (ToolTipInfo)m_controls[control]; info.IconType = type; if (info.TipText.Length == 0 && info.TipTitle.Length == 0 && info.IconType == ToolTipIconType.None) { m_controls.Remove(control); control.HandleCreated -= new EventHandler(HandleCreated); control.HandleDestroyed -= new EventHandler(HandleDestroyed); if (m_addedList.Contains(control)) { DestroyRegion(control); m_addedList.Remove(control); } } } }
private void CreateRegion(Control ctl) { if (!m_controls.ContainsKey(ctl)) { return; } ToolTipInfo info = (ToolTipInfo)this.m_controls[ctl]; bool flag = info.TipText.Length > 0 || info.TipTitle.Length > 0 || info.IconType != ToolTipIconType.None; if (flag && !this.m_addedList.Contains(ctl) && !base.DesignMode) { int num1 = (int)NativeMethods.SendMessage(new HandleRef(this, this.Handle), NativeMethods.TTM_ADDTOOL, 0, this.GetTOOLINFO(ctl)); if (num1 == 0) { throw new InvalidOperationException("error:" + NativeMethods.GetLastError()); } this.m_addedList.Add(ctl); } }
/// <summary> /// ��������Ŀؼ� /// </summary> /// <param name="control"></param> /// <param name="text"></param> public virtual void SetToolTip(Control control, string text) { bool bNewControl,bValidText; if (control == null) { throw new ArgumentNullException("control"); } bNewControl = !m_controls.ContainsKey(control); bValidText = (text != null && text.Length > 0); if (bNewControl) { if (bValidText) { ToolTipInfo info = new ToolTipInfo(text,"",ToolTipIconType.None); m_controls.Add(control,info); control.HandleCreated += new EventHandler(HandleCreated); control.HandleDestroyed += new EventHandler(HandleDestroyed); if (control.IsHandleCreated) { this.HandleCreated(control,EventArgs.Empty); } } } else { ToolTipInfo info = (ToolTipInfo)m_controls[control]; info.TipText = text; if (info.TipText.Length == 0 && info.TipTitle.Length == 0 && info.IconType == ToolTipIconType.None) { m_controls.Remove(control); control.HandleCreated -= new EventHandler(HandleCreated); control.HandleDestroyed -= new EventHandler(HandleDestroyed); if (m_addedList.Contains(control)) { DestroyRegion(control); m_addedList.Remove(control); } } } }
public void SetIconType(Control control,ToolTipIconType type) { bool bNewControl; if (control == null) { throw new ArgumentNullException("control"); } bNewControl = !m_controls.ContainsKey(control); if (bNewControl) { if (type != ToolTipIconType.None) { ToolTipInfo info = new ToolTipInfo("","",type); m_controls.Add(control,info); control.HandleCreated += new EventHandler(HandleCreated); control.HandleDestroyed += new EventHandler(HandleDestroyed); if (control.IsHandleCreated) { this.HandleCreated(control,EventArgs.Empty); } } } else { ToolTipInfo info = (ToolTipInfo)m_controls[control]; info.IconType = type; if (info.TipText.Length == 0 && info.TipTitle.Length == 0 && info.IconType == ToolTipIconType.None) { m_controls.Remove(control); control.HandleCreated -= new EventHandler(HandleCreated); control.HandleDestroyed -= new EventHandler(HandleDestroyed); if (m_addedList.Contains(control)) { DestroyRegion(control); m_addedList.Remove(control); } } } }