2012-08-03 105 views
3

在运行时,我创建一个所有者绘制工具提示,在弹出事件中设置我的工具提示窗口的大小,并在绘制事件中设置文本。如何设置所有者绘制工具提示的位置?

public void NewLabel(string aText) 
{ 
    ToolTip tt = new ToolTip(); 
    tt.Popup += new PopupEventHandler(tt_Popup); 
    tt.Draw += new DrawToolTipEventHandler(tt_Draw); 

    tt.BackColor = Color.White; 
    tt.AutomaticDelay = 100; 
    tt.AutoPopDelay = 35000; 
    tt.IsBalloon = false; 
    tt.OwnerDraw = true; 
    tt.SetToolTip(aLabel, sToolTip); 
} 

public void tt_Popup(object sender, PopupEventArgs e) 
{ 
    e.ToolTipSize = new Size(e.ToolTipSize.Width + 300, e.ToolTipSize.Height + 200); 
} 

public void tt_Draw(object sender, DrawToolTipEventArgs e) 
{ 
    e.DrawBackground(); 
    e.DrawBorder(); 
} 

这工作得很好,但问题是,如果我的工具提示抽奖活动是由控制在我的屏幕底部发射时,工具提示中不可视区域automaticaly像标准提示不设置。

有什么想法?

+0

它是Frameworks 3.5上的WinForms应用程序 – Peter 2012-08-06 18:14:35

回答

-2

工具提示将检查其矩形在屏幕上,如果需要,在调用Show时使用其现有尺寸移动自身。这发生在Popup之前。该框架确实会查看返回的工具提示大小,但它用于调整宽度和高度,而不是在窗口不适合时重新定位窗口。

我还没有尝试过,但我认为您必须自己移动弹出框以确保它保持在屏幕上。