读书人

关于热区编程有关问题请问

发布时间: 2012-01-26 19:40:46 作者: rapoo

关于热区编程问题请教
我在picturebox控件中加载了一图片,我需要从数据库中提取座标,从而在图片上开成几个热区,鼠标移上去变成手形,并在点击时发出不同的声音
我的问题是
1、数据库中的座标我不知道单位是什么,估计是twip,我怎么转换成像素?
2、鼠标移至热区变成手形,并在点击时发出不同的声音,这应该在哪个事件中写代码?

[解决办法]
//以下代码指定热区
static GraphicsPath gps = new GraphicsPath(new Point[]{new Point(11,166),new Point(56,255),new Point(222,256),
new Point(306,163),new Point(211,58),new Point(11,166)},new byte[]{(byte)PathPointType.Start,
(byte)PathPointType.Line,(byte)PathPointType.Line,(byte)PathPointType.Line,(byte)PathPointType.Line,
(byte)PathPointType.Line});
Region rgn1 = new Region(gps);
//处理鼠标move
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
toolStripStatusLabel1.Text = e.Location.X.ToString() + "," + e.Location.Y.ToString();
if (rgn1.IsVisible(e.Location)) this.Cursor = Cursors.Hand;
else this.Cursor = Cursors.Default;
}

你应该是需要绝对坐标的。

读书人网 >VB Dotnet

热点推荐