画完一个图形后,当再次选中图形,怎样让光标在图形中闪烁处于输入文本的状态。
不如:画一个矩形,鼠标选中后光标就在矩形内闪烁,有点像TextBox或Label。gdi+textbox

解决方案 »

  1.   

    点击的时候直接创建一个TextBox,离开焦点之后隐藏取文本绘制到图中。
      

  2.   


    不是图片,是用GDI手动绘制的图形如矩形等,光标可以在矩形中闪动和输入文本。。
      

  3.   

    谢谢:
    不是图片,是用GDI手动绘制的图形如矩形等,矩形绘制完成后再次选中时光标可以在矩形中闪动和输入文本。。
      

  4.   

    判断,鼠标单击的坐标是不是在所画图形内部,在的话再中点创建个textbox再让其获取焦点,但是不规则多边形形比较难搞..
      

  5.   


    补充:就像在Excel里 插入 “艺术字”一样的效果,字可以随外框拉伸、旋转,不是Word里的艺术字哦
      

  6.   

    private void DrawCursorsOnForm(Cursor cursor)
    {
       // If the form's cursor is not the Hand cursor and the 
       // Current cursor is the Default, Draw the specified 
       // cursor on the form in normal size and twice normal size.
       if(this.Cursor != Cursors.Hand & 
         Cursor.Current == Cursors.Default)
       {
          // Draw the cursor stretched.
          Graphics graphics = this.CreateGraphics();
          Rectangle rectangle = new Rectangle(
            new Point(10,10), new Size(cursor.Size.Width * 2, 
            cursor.Size.Height * 2));
          cursor.DrawStretched(graphics, rectangle);
            
          // Draw the cursor in normal size.
          rectangle.Location = new Point(
          rectangle.Width + rectangle.Location.X, 
            rectangle.Height + rectangle.Location.Y);
          rectangle.Size = cursor.Size;
          cursor.Draw(graphics, rectangle);      // Dispose of the cursor.
          cursor.Dispose();
       }
    }cursor.Draw试试
      

  7.   

    如果可以使用WPF,直接用WPF。如果用GDI的话,基本上要重写一个TextBox控件了,难度很大。主要需要解决输入问题。
      

  8.   

    你好,我用的是GDI,能详细的说下吗?
      

  9.   

    首先  光标输入文本是可行的  版主做过例子 
    建议你自定义一个类似textBox的控件  必竟系统控件能做的只有那么多
      

  10.   

    http://blog.csdn.net/bdmh/article/details/6456353
    这是在窗体上显示光标
      

  11.   

    自定义TextBox,主要要解决调用IME输入法,然后要自己捕获IME传过来的字符。原来看过一个帖子写这个的,不过网址不记得了,自己搜搜。
      

  12.   

    旋转绘制文字太简单了,Graphics对象有个旋转的方法
    g.Rotate 好像是这个。然后就按正常的绘制就行了。绘制完成之后恢复,也有个方法的。
    反正系统都给你包装好了,直接调用下就行了。主要是捕获输入法传过来的文字,这个是最难的,.net没提供,需要自己处理