Réponse acceptée !
Salut, encore une fois il faut passer par l'API Win32 :
public partial class Form1 : Form
{
private const int SWP_NOACTIVATE = 0x0010;
private const int SWP_SHOWWINDOW = 0x0040;
[ System.Runtime.InteropServices.DllImport( "user32.dll", SetLastError = true ) ]
private static extern bool SetWindowPos
(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int x,
int y,
int cx,
int cy,
uint flags
);
public Form1( )
{
InitializeComponent( );
Label lb = new Label( );
lb.Location = new Point( 50, 50 );
lb.BackColor = Color.AliceBlue;
lb.MouseHover += delegate
{
Form f = new Form( );
//f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
//f.ShowInTaskbar = false;
Rectangle r = lb.RectangleToScreen( lb.ClientRectangle );
SetWindowPos
(
f.Handle,
IntPtr.Zero,
r.Right + 10,
r.Top - 10,
150,
100,
SWP_NOACTIVATE | SWP_SHOWWINDOW
);
f.Visible = true; // Sinon 'Visible' reste false.
};
this.Controls.Add( lb );
}
}