我想获取ToolStripButton图像的位置,我该怎么做?我试过这样的话:
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 ;)
}
}
但是x和y总是0,位置似乎也是0,所以我怎样才能获得图像的位置? boundRect.Location始终为0 ..