to jbas:
判断rxrichedit里是图片还是文字,你需要用到剪贴板;
利用剪贴板的HasFormat事件。
CF_TEXT Text with a CR-LF combination at the end of each line. A null character identifies the end of the text.
CF_BITMAP A Windows bitmap graphic.
CF_METAFILEPICT A Windows metafile graphic.
CF_PICTURE An object of type TPicture.
CF_COMPONENT Any persistent object.
procedure TForm1.Button1Click(Sender: TObject);//加载图片
var
Pict :TPicture;
begin
with OpenPictureDialog1 do begin
if Execute then begin
Pict := TPicture.Create;
try
Pict.LoadFromFile(FileName);
Clipboard.Assign(Pict);
RxRichEdit1.PasteFromClipboard;
finally
Pict.Free;
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);//判断rxrichedit里是图片
begin
RxRichEdit1.CopyToClipboard;
if Clipboard.HasFormat(CF_BITMAP) then
ShowMessage('图片');
end;
而判断是文字你则需要加上 : RxRichEdit1.SelectAll;