Page 1 of 1

Error when processing insertpicture.

Posted: Tue Jun 28, 2016 4:13 am
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;

Posted: Tue Jun 28, 2016 3:20 pm
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;