位置标志怎么画?
我用 C# 为 Winforms 编写了自己的文本框控件。
我无法弄清楚的一件事:如何绘制各种尺寸的文本位置标志?
I writing my own textbox control in C# for Winforms.
One thing i can't figure out: how to draw the text position sign in various sizes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它被称为“插入符号”。 winapi 函数没有被 winform 封装,您必须 pinvoke 它们。从开始阅读。您可以在我的答案此处<找到代码/a>.
It is called the 'caret'. The winapi functions are not wrapped by winforms, you'll have to pinvoke them. Start reading here. You'll find code in my answer here.
试试这个。
我创建了一个方法,该方法旨在从您正在绘制的任何控件的绘画处理程序中调用。为简单起见,我只在我的表单中使用了表单本身。您可能有一个面板或其他一些控件。
该方法接受图形对象、光标的比例以及开始绘制的上/左位置。比例只是高度,但所有数学运算都是相对于高度进行的。您可以按照您想要的方式调整这些数字。
此示例产生以下输出:
Try this.
I created a method which is meant to be called from the paint handler of whichever control you're drawing in. For simplicity I just used the form itself in mine. You probably have a panel or some other control.
The method accepts the graphics object, the scale of the cursor and the upper/left position of where to start drawing. The scale is just the height but all the math is performed relative to the height. You can tweak those numbers any way you want.
This sample produces the following output: