2

I would like to get the location of the the image of an ToolStripButton, how can i do that? I tried it like this:

private void ToolStripButton_MouseHover(object sender, EventArgs e)
{
    Graphics formGraphics = this.CreateGraphics();
    GraphicsUnit units = GraphicsUnit.Point;
    RectangleF imageBoundsF = reloadToolStripButton.Image.GetBounds(ref units);
    Rectangle boundRect = Rectangle.Round(imageBoundsF);
    Size imageSize = new Size(reloadToolStripButton.Image.Width, reloadToolStripButton.Image.Height);
    Rectangle imageRect = new Rectangle(boundRect.Location, imageSize);
    formGraphics.Dispose();

    if (imageRect.Contains(Cursor.Position))
    {
        // Do what i want ;)
    }
}

But x and y are always 0 and the location also seems to be 0, so how can i get the location of the image? boundRect.Location is always 0 ..

Procos
  • 94
  • 9

0 Answers0