-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyTooltip.cs
37 lines (32 loc) · 1.02 KB
/
MyTooltip.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Drawing;
using System.Windows.Forms;
namespace ProcessMonitor
{
class MyToolTip : System.Windows.Forms.ToolTip
{
public MyToolTip()
{
OwnerDraw = true;
Draw += OnDrawEvent;
Popup += OnPopupEvent;
}
void OnDrawEvent(object sender, DrawToolTipEventArgs e)
{
// Draw the background and border.
//e.DrawBackground();
e.DrawBorder();
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
int Margin = 5;
int image_wid = 2 * Margin + 100;
Rectangle rect = new Rectangle(image_wid, 0, e.Bounds.Width - image_wid, e.Bounds.Height);
e.Graphics.DrawString(e.ToolTipText, e.Font, Brushes.Green, rect, sf);
}
void OnPopupEvent(object sender, PopupEventArgs e)
{
e.ToolTipSize = new Size(100, 100);
}
}
}