public class ShieldLink : Button
{
private const int BS_COMMANDLINK = 0x0000000E;
private const uint BCM_SETNOTE = 0x00001609;
private const uint BCM_SETSHIELD = 0x0000160C;
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg,
IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg,
IntPtr wParam, IntPtr lParam);
public ShieldLink()
{
this.FlatStyle = FlatStyle.System;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= BS_COMMANDLINK;
return cp;
}
}
private string _textNote;
public string TextNote
{
get
{
return _textNote;
}
set
{
_textNote = value;
SendMessage(new HandleRef(this, this.Handle), BCM_SETNOTE,
IntPtr.Zero, value);
}
}
private bool _showShield;
public bool ShowShield
{
get
{
return _showShield;
}
set
{
_showShield = value;
SendMessage(new HandleRef(this, this.Handle),
BCM_SETSHIELD, IntPtr.Zero, new IntPtr(value ? 1 : 0));
}
}
}
Come nota personale, trovo molto carino l'effetto di fade out quando si sposta il mouse fouri dal controllo