trichview.com

trichview.support




InsertPicture


Return to index


Author

Message

Walter Mrak

Posted: 04/29/2003 15:41:33


Hi,


In the onPaste Event of a TDBRichViewEdit Component I want to change all

Bitmaps into JPegs.

If I call the InsertPicture Method an AccessViolation occures.

Here is the Source:


procedure TfrmOra.DBRichViewEdit1Paste(Sender: TCustomRichViewEdit;

  var DoDefault: Boolean);

var I: Integer;

    Jpg: TJPEGImage;

    Bmp: TBitmap;

begin

  for I := 0 to Clipboard.FormatCount - 1 do begin

    ListBox1.Items.Add(IntToStr(Clipboard.Formats[I]));

    if Clipboard.Formats[I] = CF_BITMAP then begin

      Jpg := TJPEGImage.Create;

      Bmp := TBitmap.Create;

      try

        Bmp.LoadFromClipboardFormat(CF_BITMAP, ClipBoard.GetAsHandle(CF_BITMAP),

0);

        Jpg.CompressionQuality := 50;

        Jpg.Assign(Bmp);

        Jpg.Compress;

        DBRichViewEdit1.InsertPicture('', Jpg, rvvaBaseline);

        DoDefault := False;

      finally

        Bmp.Free;

        Jpg.Free;

      end; // End Finally

    end; // end if

  end;

end;


Do You know where the Problem is?


Walter





Powered by ABC Amber Outlook Express Converter