全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2352
推到 Plurk!
推到 Facebook!

哪位元大哥知道如何在RICHEDIT中插入圖片對像,並且讓圖片不能編緝或改變尺寸(不能設爲唯讀)?

尚未結案
ychx
一般會員


發表:40
回覆:14
積分:10
註冊:2003-08-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-02 16:31:24 IP:218.0.xxx.xxx 未訂閱
哪位元大哥知道如何在RICHEDIT中插入圖片對像,並且讓圖片不能編緝或改變尺寸(不能設爲唯讀)?
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-02-04 01:10:34 IP:218.163.xxx.xxx 未訂閱
引言: 哪位元大哥知道如何在RICHEDIT中插入圖片對像,並且讓圖片不能編緝或改變尺寸(不能設爲唯讀)?
//參考看看 http://www.swissdelphicenter.ch/torry/showcode.php?id=1332
 
uses 
  RichEdit;     // Stream Callback function 
type 
  TEditStreamCallBack = function(dwCookie: Longint; pbBuff: PByte; 
    cb: Longint; var pcb: Longint): DWORD; 
  stdcall;       TEditStream = record 
    dwCookie: Longint; 
    dwError: Longint; 
    pfnCallback: TEditStreamCallBack; 
  end;     // RichEdit Type 
type 
  TMyRichEdit = TRxRichEdit;     // EditStreamInCallback callback function 
function EditStreamInCallback(dwCookie: Longint; pbBuff: PByte; 
  cb: Longint; var pcb: Longint): DWORD; stdcall; 
  // by P. Below 
var 
  theStream: TStream; 
  dataAvail: LongInt; 
begin 
  theStream := TStream(dwCookie); 
  with theStream do 
  begin 
    dataAvail := Size - Position; 
    Result := 0; 
    if dataAvail <= cb then 
    begin 
      pcb := read(pbBuff^, dataAvail); 
      if pcb <> dataAvail then 
        Result := UINT(E_FAIL); 
    end 
    else 
    begin 
      pcb := read(pbBuff^, cb); 
      if pcb <> cb then 
        Result := UINT(E_FAIL); 
    end; 
  end; 
end;     // Insert Stream into RichEdit 
procedure PutRTFSelection(RichEdit: TMyRichEdit; SourceStream: TStream); 
  // by P. Below 
var 
  EditStream: TEditStream; 
begin 
  with EditStream do 
  begin 
    dwCookie := Longint(SourceStream); 
    dwError := 0; 
    pfnCallback := EditStreamInCallBack; 
  end; 
  RichEdit.Perform(EM_STREAMIN, SF_RTF or SFF_SELECTION, Longint(@EditStream)); 
end;     // Convert Bitmap to RTF Code 
function BitmapToRTF(pict: TBitmap): string; 
// by D3k 
var 
  bi, bb, rtf: string; 
  bis, bbs: Cardinal; 
  achar: ShortString; 
  hexpict: string; 
  I: Integer; 
begin 
  GetDIBSizes(pict.Handle, bis, bbs); 
  SetLength(bi, bis); 
  SetLength(bb, bbs); 
  GetDIB(pict.Handle, pict.Palette, PChar(bi)^, PChar(bb)^); 
  rtf := '{\rtf1 {\pict\dibitmap '; 
  SetLength(hexpict, (Length(bb)   Length(bi)) * 2); 
  I := 2; 
  for bis := 1 to Length(bi) do 
  begin 
    achar := Format('%x', [Integer(bi[bis])]); 
    if Length(achar) = 1 then 
      achar := '0'   achar; 
    hexpict[I - 1] := achar[1]; 
    hexpict[I] := achar[2]; 
    Inc(I, 2); 
  end; 
  for bbs := 1 to Length(bb) do 
  begin 
    achar := Format('%x', [Integer(bb[bbs])]); 
    if Length(achar) = 1 then 
      achar := '0'   achar; 
    hexpict[I - 1] := achar[1]; 
    hexpict[I] := achar[2]; 
    Inc(I, 2); 
  end; 
  rtf := rtf   hexpict   ' }}'; 
  Result := rtf; 
end;     // Example to insert image from Image1 into RxRichEdit1 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  SS: TStringStream; 
  BMP: TBitmap; 
begin 
  BMP := TBitmap.Create; 
  BMP := Image1.Picture.Bitmap; 
  SS  := TStringStream.Create(BitmapToRTF(BMP)); 
  try 
    PutRTFSelection(RxRichEdit1, SS); 
  finally 
    SS.Free; 
  end; 
end;     
網海無涯,學無止境!
ychx
一般會員


發表:40
回覆:14
積分:10
註冊:2003-08-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-02-06 21:51:26 IP:218.0.xxx.xxx 未訂閱
嗯,这个可以插入图片,但是图片是可以调整大小的,我要的是不可调整大小的, 不管怎样,还是感谢这位兄台!
系統時間:2024-03-28 22:40:45
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!