在需要插入文字的地方先显示一个文本框,输入完文字失去光标以后,文字就变成了图片的一部分了。 
在bitmap上用canvas画的。谢谢!

解决方案 »

  1.   

    在底图的canvas上画出edit的内容
      

  2.   

    一般是在画图控件上放一个编辑框(例如TEdit),在画图控件中实现鼠标点击消息,点击后将TEdit显示出来给用户输入,等输入完成(例如,监听TEdit的键盘回车键),将TEdit的坐标位置和内容(Left、Top、Text属性)记录下来,然后,调用画图控件的Invalidate函数,然后,在画图控件的OnPaint事件中在对应的位置画出来(例如Canvas.TextOut(Left, Top, Text))
      

  3.   

    伴水写的屏幕画板,开源而且强大
    http://code.google.com/p/screen-paint/
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Image1: TImage;
        Edit1: TEdit;
        procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Edit1KeyPress(Sender: TObject; var Key: Char);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
          if key =#13 then
          begin
              Image1.Canvas.Font.Color := clRed;
              Image1.Canvas.TextOut(Edit1.Left-image1.Left,Edit1.top-image1.top,Edit1.Text);
              Edit1.Visible := False;
          end;
    end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
      Pt:TPoint;
    begin  GetCursorPos(pt);
      if  WindowFromPoint(pt) =Edit1.Handle then
      begin
        ReleaseCapture;
        SetCapture(Handle) ;  end else
      begin
         ReleaseCapture;    Image1.Canvas.Font.Color := clRed;
        Image1.Canvas.TextOut(Edit1.Left-image1.Left,Edit1.top-image1.top,Edit1.Text);
        Edit1.Visible := False;
      end;end;procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);begin     Edit1.Left := x+image1.Left;
         Edit1.Top := y+image1.Top;
         edit1.Visible := True;
         SetCapture(Handle) ;
    end;end.dfm
    -------------------------
    object Form1: TForm1
      Left = 218
      Top = 96
      Caption = 'Form1'
      ClientHeight = 462
      ClientWidth = 854
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      OnMouseUp = FormMouseUp
      PixelsPerInch = 96
      TextHeight = 13
      object Image1: TImage
        Left = 168
        Top = 112
        Width = 369
        Height = 289
        OnMouseDown = Image1MouseDown
      end
      object Edit1: TEdit
        Left = 392
        Top = 320
        Width = 121
        Height = 21
        TabOrder = 0
        Text = 'Edit1'
        Visible = False
        OnKeyPress = Edit1KeyPress
      end
    end
      

  5.   

    上面用 SetCapture 把鼠标事件由from来接管。哪怕 鼠标是点击的 form外的位置 也会触发FormMouseUP
    完全可以不用mousehook了
    关于tab焦点的切换 你自己处理下就可以