为什么 controlpaint 绘制方法在其客户端绘制区域之外进行绘制?
我有一个 winform,当您单击鼠标左键并拖动时,我想在其上绘制虚线框。当释放鼠标左键时,框架应该消失。我可以使用 ControlPaint.DrawReversibleFrame 方法来做到这一点。然而,它每次都是在 winform 之外绘制,而不是在 winform 内绘制。看来 controlpaint 方法使用屏幕作为绘画区域而不是 winform。我说得对吗?
如果我的假设是正确的,你如何告诉controlpaint使用winform作为它的绘画区域。
谢谢,
I have a winform on which I want to draw dashed frame as you click the left mouse button and drag. When the left mouse button is released, the frame should disappear. I am able to do that with ControlPaint.DrawReversibleFrame method. However, it draws outside of the winform every time not within the winform. It seems controlpaint methods using the screen as the paint area not the winform. Am I correct?
If my assumption is correct, how do you tell controlpaint to use winform as its paint area.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ControlPaint 通过在桌面上绘图来“作弊”。
可以尝试的解决方法是亲自观察尺寸。一旦到达控制边界,就停止调用它。
更新:
听起来您不一定正确转换尺寸。
下面是一个始终在 panel1 控件上绘图的简单示例:
ControlPaint does "cheat" by drawing on the desktop.
A work around to try is to watch the dimensions yourself. Once you get to the border of your control, stop calling it.
Updated:
It sounds like you aren't necessarily converting your dimensions correctly.
Here is a simple example to always draw on a panel1 control: