【发布时间】:2016-07-12 02:30:02
【问题描述】:
如何检查鼠标是否点击了矩形?
Graphics gfx;
Rectangle hitbox;
hitbox = new hitbox(50,50,10,10);
//TIMER AT THE BOTTOM
gfx.Draw(System.Drawing.Pens.Black,hitbox);
【问题讨论】:
-
你的
gfx指的是什么? -
如果你的“gfx”是表单中的“e.Graphics...”,那么只需使用事件MouseDown,有e.X和e.Y.
-
永远不要使用
control.CreateGraphics!永远不要尝试缓存Graphics对象!使用Graphics g = Graphics.FromImage(bmp)或在控件的Paint事件中使用e.Graphics参数绘制到Bitmap bmp中。
标签: c# windows-forms-designer hittest drawrectangle