不规则形状的按钮 [英] Irregular shaped buttons
本文介绍了不规则形状的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在寻找一种方法来检查我的光标当前是否在特定的绘图上,以便可以突出显示它.
假设这可能是形状:
Hello everyone,
I am looking for a method to check if my cursor is currently over a specific draw so it can be highlighted.
Let''s say this is may shape:
___________
/ /
/__________/
如您所见,有一些备用空间(按钮通常是直框).
如何排除剩余空间?
大家知道,我使用GraphicsPath绘制了线条.
As you can obviously see, there''s a bit of spare space (buttons are usually straight boxes).
How can I exclude the spare space?
Just so you know, I draw the lines using a GraphicsPath.
推荐答案
检查光标坐标(作为Point类型)是否在该区域内. >
Check if the cursors coordinates (as a Point type) lie within in that region.
Pont point = ...; //Set mouse coordinates here.
GraphicsPath path = ...; // Create your path here.
if(path.IsVisible(point)) ... // Check if mouse coordinates are within path
问候,
-MRB
Regards,
-MRB
如Manfred所说,将您的Path转换为Region并使用 ^ ]方法.
As Manfred has said, convert your Path to a Region and use the Region.IsVisible(Point)[^] method.
所有其他答案都不完全正确.它们仅有助于定义可见区域或以特殊方式处理鼠标事件.最终的解决方案是:
在按钮HWND
上使用Windows APISetWindowRgn
.它将在各个方面将按钮Windows塑造成一个区域,不仅是视觉上的,而且仅当鼠标事件发生在指定区域内时,鼠标事件才会被自动路由.请参阅 http://msdn.microsoft.com/en-us/library/dd145102(v = vs.85).aspx [
All other answers are not quite correct. They only help to define visible area or process mouse events in a special way. The ultimate solution is this:
Use Windows APISetWindowRgn
on a buttonHWND
. It will shape a buttons Windows to a region in all aspects, not just visual, but the mouse event will be automatically routed only if they happen within the specified region. See http://msdn.microsoft.com/en-us/library/dd145102(v=vs.85).aspx[^].
—SA
这篇关于不规则形状的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文