2012-08-03 54 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之前。該框架確實會查看返回的工具提示大小,但它用於調整寬度和高度,而不是在窗口不適合時重新定位窗口。

我還沒有嘗試過,但我認爲您必須自己移動彈出框以確保它保持在屏幕上。