我的看法是,在EDIT里的恰当的位置插入TImage,然后把图片显示在TImage里!
一点意见,请指正!

解决方案 »

  1.   

    估计要继承 TCustomControl 来写了
      

  2.   

    用BilBlt APi重绘, 我曾在Combox中用过。  
      

  3.   

    to net_z
        怎样重绘?
      

  4.   

    能让他随光标移动好想是OLE嵌入的事,注册VB的Richtext控件最简单
      

  5.   

    在BCB中的解决方案如下:1。重载要替代的编辑框中的窗口过程。
      在Form中加入成员TWndMothod OldWndProc;
      在Form中加入成员TImage* Image;
      在Form中加入函数void __fastcall MyWndProc(TMessage& Message);
      在Form的构造函数中写入
            OldWndProc = Edit1->WindowProc;
            Edit1->WindowProc = MyWndProc;
            Image = NULL;
    2.在void __fastcall MyWndProc(TMessage& Message)函数的实现中加入如下代码

      void __fastcall TForm1::MyWndProc(TMessage& Message)
    {
        OldWndProc(Message);
        switch(Message.Msg)
        {
            case WM_SETFOCUS:
            {
                if (Image != NULL)
                    return;            Image = new TImage(Edit1);
                Image->Parent = Edit1;
                Image->Picture->LoadFromFile("yourFileName.bmp");            POINT cp;
                if(!GetCaretPos(&cp))
                    return;
                Image->Top = cp.y;
                Image->Left = cp.x;            return;
            }        case WM_KILLFOCUS:
            {
                delete Image;
                Image = NULL;
                return;
            }        case WM_CHAR:
            {
                POINT cp;
                if(!GetCaretPos(&cp))
                    return;
                Image->Top = cp.y;
                Image->Left = cp.x;            return;
            }    
        }
    }
    在Delphi中如何改?
      

  6.   

    是否有人可以给出DELPHI中解决方案???
      

  7.   

    var
    canvas:Tcanvas;canvas:=Tcanvas.Create;
    canvas.Handle:=getdc(edit1.Handle);
    在edit1的onChange中算x
    canvas.Draw(x,y,graphic);
      

  8.   

    这是Delphi的翻译,只是一段一段的翻,没有查过是不是对的,不过,Delphi是很强大的东东,而BCB和Delphi的底层是一个东东。  在Form中加入成员OldWndProc:TWndMothod;
      声明个指针PImage:^TImage;
      在Form中加入函数MyWndProc(var Message:TMessage);stdcall;
      在Form.Create中写入
            OldWndProc = Edit1.WindowProc;
            Edit1.WindowProc = MyWndProc;
            PImage = nil;
    2.在MyWndProc(var Message:TMessage)函数的实现中加入如下代码  TForm.MyWndProc(var Message:TMessage);stdcall;
      var
         cp:pointer;
      begin
        OldWndProc(Message);
        case Message.Msg of
            WM_SETFOCUS:
            begin
                if PImage<>nil then
                    exit;            PImage:=new(TImage(Edit1));
                PImage.Parent:= Edit1;
                PImage.Picture.LoadFromFile("yourFileName.bmp");
                if (!GetCaretPos(@cp))
                    exit;
                PImage.Top := cp.y;
                PImage.Left := cp.x;
             end;
             WM_KILLFOCUS:
             begin           
                decllocate(PImage);
                PImage := nil;
             end
             WM_CHAR:
             begin
                if (!GetCaretPos(&cp)) then
                    exit;
                PImage.Top := cp.y;
                PImage.Left := cp.x;         end
          end
    end
      

  9.   

    var canvas:Tcanvas;
       icon:Ticon;
       sh:TSHFileInfoA;
    begin
     try  
       icon:=Ticon.create;
       canvas:=Tcanvas.Create;
       canvas.Handle:=getdc(edit1.handle);
       shgetfileinfo('d:\abc.exe',0,sh,sizeof(sh),SHGFI_ATTRIBUTES or SHGFI_ICON or SHGFI_SMALLICON);
       icon.Handle:=sh.hIcon;
       canvas.Draw(0,0,icon);
       canvas.textout(icon.width div 2,0,edit1.text);
       Invalidate;
      finally
        icon.free;
        canvas.free;
      end;
    end;
    试试吧
      

  10.   

    得到Canvas后想在上面画什么都可以的。你试试它的方法就知道了。