文本框中怎么能插入图像?像MSN中那样(150分)

  • 主题发起人 主题发起人 Clark-Kidd
  • 开始时间 开始时间
C

Clark-Kidd

Unregistered / Unconfirmed
GUEST, unregistred user!
不要Draw出来的,我想要MSN对话框中那样,可以选中的,最好还能删除。
有这样的控件吗?在线等待,谢谢大家。
 
QQ中发送消息的框的使用的是RichEdit.MSN中也是.我用SPY++看的.可以显示小图片.以上说的是发送的消息框.不知你问的是不是?
 
用RichEdit确实可以实现
 
是的,我要的就是这个效果。
我今天在查看 RichEdit 的 Help,但是没有什么发现,可以给我个例子吗?或者关于这方面的文章
 
你看一下下面的网页中的效果是否符合要求:
http://www.codeguru.com/richedit/richeditrc.html
它使用的是VC,我以前学的VC,我看看在Delphi中怎么用.
我想在VC中和Delphi调用的函数应该是一样的,你可以作为参考
 
上面的那个例子太麻烦了,你再看看这个,虽然用的是第三方控件,但是可以参考.
http://www.csdn.net/develop/article/15/15089.shtm
我试着也做做.如果你做出来的话,可不可以发我一份.
matrixss@sina.com.cn. 1M以上就算了
 
to matricss,下面是从csdn上抄过来的(你上面的连接),完全可以实现,美中不足的是
要用TRxRichEdit控件,我用TRichEdit控件试了一下,好象不行。
下面是抄来的代码:
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RxRichEd;

type
TForm2 = class(TForm)
RxRichEdit1: TRxRichEdit;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

function ConvertBitmapToRTF(const Bitmap: TBitmap): string;
var
bi, bb: string;
bis, bbs: Cardinal;
achar: string[2];
Buffer: string;
I: Integer;
type
PWord = ^Word;
begin
GetDIBSizes(Bitmap.Handle, bis, bbs);
SetLength(bi, bis);
SetLength(bb, bbs);
GetDIB(Bitmap.Handle, Bitmap.Palette, PChar(bi)^, PChar(bb)^);
SetLength(Buffer, (Length(bb) + Length(bi)) * 2);
i := 1;
for bis := 1 to Length(bi) do
begin
achar := IntToHex(Integer(bi[bis]), 2);
PWord(@Buffer)^ := PWord(@achar[1])^;
inc(i, 2);
end;
for bbs := 1 to Length(bb) do
begin
achar := IntToHex(Integer(bb[bbs]), 2);
PWord(@Buffer)^ := PWord(@achar[1])^;
inc(i, 2);
end;
Result := '{/rtf1 {/pict/dibitmap ' + Buffer + ' }}';
end;

procedure InsertBitmapIntoRxRichEdit(const Bitmap: TBitmap; const RxRichEdit:
TRxRichEdit); overload;
begin
RxRichEdit.SelText := ConvertBitmapToRTF(Bitmap);
RxRichEdit.SelLength := 0;
RxRichEdit.SelStart := RxRichEdit.SelStart + 1;
end;

procedure InsertBitmapIntoRxRichEdit(const GraphicFileName: string; const
RxRichEdit: TRxRichEdit); overload;
var
Bitmap: TBitmap;
Graphic: TPicture;
begin
Graphic := TPicture.Create;
try
Graphic.LoadFromFile(GraphicFileName);

if Graphic.Graphic is TBitmap then
Bitmap := Graphic.Bitmap
else
begin
Bitmap := TBitmap.Create;
Bitmap.Assign(Graphic.Graphic);
end;

InsertBitmapIntoRxRichEdit(Bitmap, RxRichEdit);
finally
if Bitmap <> Graphic.Bitmap then
FreeAndNil(Bitmap);

FreeAndNil(Graphic);
end;
end;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
InsertBitmapIntoRxRichEdit(edit1.Text, RxRichEdit1);
RxRichEdit1.SetFocus;
end;

end.
 
谢谢大家,请问 TRxRichEdit 哪里下载啊?
 
我的网站上有:
http://www.donghe-hk.com/yyh/DelphiDatum/Rx275.rar
 
to 特尔斐:
你也试了吗?我也试了,结果一样:不行.
今天精神不是很好,改天查查MSDN.
RichEdit应该有这功能,因为在我找的第一个网站上已经实现了,只不过看不懂,呵呵.
 
好东西,我找了半天就是找不到for D6和D7的,谢谢。
我调试看看,没什么问题就散分了,谢谢两位!
 
msn中好像使用ListView做的吧?
用listview没那么麻烦
 
richedit可以呀
 
多人接受答案了。
 
后退
顶部