Error when processing insertpicture.

General TRichView support forum. Please post your questions here
Post Reply
DelphiDude
Posts: 17
Joined: Sun Mar 27, 2016 5:15 pm

Error when processing insertpicture.

Post by DelphiDude »

here is my code for finding text and insertpicture, but i keep getting invalid pointer error.

Code: Select all

procedure TfrmHKLDocuments.SearchAndReplaceImage(InSearch: string; NewImage : TWICImage);
var
  APos: Integer;
begin
    _bitmap := TBitmap.Create;
    _bitmap.Assign(nil);
    _bitmap.Assign(NewImage);
    ResizeBitmap(_bitmap, 210, 40, clWhite);
    begin
    rveDoc.ActiveEditor.SetSelectionBounds(
      0, rveDoc.ActiveEditor.GetOffsBeforeItem(0),
      0, rveDoc.ActiveEditor.GetOffsBeforeItem(0));
    while (rveDoc.ActiveEditor.SearchText(InSearch,[RVEdit.TRVESearchOption.rvseoDown
        ])) do
        begin
        rveDoc.RichViewEdit.InsertPicture('',_bitmap, rvvaBaseline);
        end;
    end;
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You cannot insert the same image multiple times

Code: Select all

procedure TfrmHKLDocuments.SearchAndReplaceImage(InSearch: string; NewImage : TWICImage); 
 var 
   APos: Integer; 
 begin 
     begin 
     rveDoc.ActiveEditor.SetSelectionBounds( 
       0, rveDoc.ActiveEditor.GetOffsBeforeItem(0), 
       0, rveDoc.ActiveEditor.GetOffsBeforeItem(0)); 
     while (rveDoc.ActiveEditor.SearchText(InSearch,[RVEdit.TRVESearchOption.rvseoDown 
         ])) do 
         begin 
       _bitmap := TBitmap.Create; 
       _bitmap.Assign(nil); 
       _bitmap.Assign(NewImage); 
       ResizeBitmap(_bitmap, 210, 40, clWhite); 
         rveDoc.RichViewEdit.InsertPicture('',_bitmap, rvvaBaseline); 
         end; 
     end; 
 end; 
Post Reply