向表单的控制框添加按钮?
我正在寻找一种向表单的控制框添加按钮的方法。 我不在乎它是哪种语言,但我希望它是 .NET(C#、VB.NET 或 C++)版本。
是的,我已经看到这个,并且答案中的解决方案都不起作用,至少对于 Windows 7. 是的,我知道这个< /a> 也可以,但我正在寻找一种更自然/原生的方式(如果有的话)。
I am looking for a way to add buttons to a form's control box.
I don't care in which language it is, but I'd love to have it in .NET (C#, VB.NET or C++).
Yes, I have seen this and none of the solutions in the answer work, at least for Windows 7.
And yes, I know this one too, it works, but I am looking for a more natural/native way, if there is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种方法可能是使用无边框表单并放置您自己的标题栏。就像这里所示:
CodeProject 上的 gTitleBar
An alternate way could be having a border less form and put your own TitleBar. Like shown here :
gTitleBar on CodeProject
正如 Tergiver 在他的评论中所说,没有什么好的方法可以做到这一点,我建议在大多数情况下根本不应该这样做,因为它确实不标准并且会让用户感到困惑。
但是,如果您确实需要这样做,那么我认为执行此操作的方法是监听
WM_NCPAINT
消息(在WndProc
内),当您得到其中之一是您手动绘制自己的按钮。然后,您必须在绘制按钮的区域监听鼠标事件,并手动处理这些点击。As Tergiver says in his comment, there's no nice way of doing this, and I'd recommend that in most circumstances it shouldn't be done at all since it'll be really non-standard and confusing to the users.
However, if you do really need to do it, then I think that the way to do it would be to listen for the
WM_NCPAINT
message (insideWndProc
) and when you get one of those you paint your own button manually. Then you'll have to listen out for mouse events in the area where your button has been drawn and handle those clicks manually also.