Я добавил обработчик Draw для рисования подсказок в приложении, функция Draw устанавливает шрифт и размер с фиксированным пространством, однако в результате ограничивающий прямоугольник, переданный через параметр DrawToolTipEventArgs, требует настройки.Мне нужно изменить его, поскольку при вызове функций DrawBackground и DrawBorder используется неправильный ограничивающий прямоугольник.
Как настроить ограничивающий прямоугольник в случае?
Это код, в котором я настраиваю элемент управления ToolTip:
this.ToolTip1.Draw += ToolTip1_Draw;
this.ToolTip1.Popup += ToolTip1_Popup;
this.ToolTip1.OwnerDraw = true;
this.ToolTip1.ReshowDelay = 10;
Я вижу, что ToolTip1_Draw вызывается, но ToolTip1_Popup никогда не вызывается. Обработчики:
private void ToolTip1_Draw(object sender, DrawToolTipEventArgs e) {
using (Graphics g = this.CreateGraphics()) {
using (StringFormat sf = new StringFormat()) {
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Near;
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
sf.FormatFlags = StringFormatFlags.NoWrap;
using (Font f = new Font("Courier New", 8)) {
e.DrawBackground();
e.DrawBorder();
e.Graphics.DrawString(e.ToolTipText, f
, SystemBrushes.ActiveCaptionText
, e.Bounds, sf);
}
}
}
}
private void ToolTip1_Popup(object sender, PopupEventArgs e) {
using (Font f = new Font("Courier New", 8)) {
e.ToolTipSize = TextRenderer.MeasureText(
ToolTip1.GetToolTip(e.AssociatedControl), f);
}
}
Кто-нибудь может понять, почему ToolTip1_Popup не вызывается?
[Изменить] В IDE у меня есть точка останова в ToolTip1_Popup
code> там стоит восклицательный знак, там написано:
The breakpoint will not currently be hit. No executable code of the debugger's target code type is associated with this line.
Possible causes include: conditional compilation, compiler optimizations, or the target architecture of this line is not supported by the current debugger code type.
Некоторая информация об используемой мной IDE:
Microsoft Visual Studio Professional 2022 (64-Bit) - Current
Version 17.8.6
Операционная система:
Microsoft Windows [Version 10.0.19045.4291]
Подробнее здесь: https://stackoverflow.com/questions/785 ... peventargs