【提问】怎么判断鼠标点击在了一个不规则形状的区域

【提问】如何判断鼠标点击在了一个不规则形状的区域
RT
举个简单的例子说明,比如中国地图,我如何判断,鼠标点击在吉林省的范围内。
鼠标 不规则区域

------解决方案--------------------
PtInRegion
The PtInRegion function determines whether the specified point is inside the specified region. 

BOOL PtInRegion(
  HRGN hrgn,  // handle to region
  int X,      // x-coordinate of point
  int Y       // y-coordinate of point
);
 
Parameters
hrgn 
Handle to the region to be examined. 

Specifies the x-coordinate of the point. 

Specifies the y-coordinate of the point. 
Return Values
If the specified point is in the region, the return value is nonzero.

If the specified point is not in the region, the return value is zero. 

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in wingdi.h.
  Import Library: Use gdi32.lib.

See Also
Regions Overview, Region Functions, RectInRegion 

 

------解决方案--------------------
1楼把具体函数都告诉你了,接下来就是那个HRGN hrgn的创建问题了,搜索一下“vc CRgn”,很简单的
------解决方案--------------------
给你个思路吧,给不同的块着不同的颜色,点下鼠标时,根据被点的点的颜色,就知道是点击的那个块了。
当然这里的“着色”不一定要是真正的着色。
------解决方案--------------------
看看这个 http://www.cnblogs.com/del/archive/2008/05/26/1207811.html关键就是其中那个区域创建函数CreatePolyPolygonRgn,注意最后那个填充模式参数,可以试一下看看都什么效果就明白了。
------解决方案--------------------
创建一个和你的地图大小一样的位图文件,各省用不同的颜色,用户点击之后将坐标值影射到位图文件上,通过颜色值判断点击了哪个省。很多Gal游戏用的好像都是这个方法。其实可以不用图片文件,主要是图片文件可以用其他的图片编辑软件编辑,更方便一些,但是占用空间会大一些,而且效率也不会很高。