Inserting an Image

The source code for this sample program is contained in the Samples\delphi\Images sample source directory.

The TForm1.Insert1Click function shows you how to open a dialog box for selecting an image file, and then insert the image:

[Delphi]
procedure TForm1.Insert1Click(Sender: TObject);
begin
    OpenDialog1.Title := 'Insert Image';
    OpenDialog1.Filename := '';
    OpenDialog1.Filter := TXTextControl1.ImageFilters;
    OpenDialog1.FilterIndex := 1;
    OpenDialog1.Options := [ofPathMustExist, ofFileMustExist, ofHideReadOnly];

    if OpenDialog1.Execute then begin
        try
            TXTextControl1.ImageInsert(OpenDialog1.Filename,-1, 1, 0, 0, 100, 100, 3, 0, 0, 0, 0);
        except
            MessageDlg('Cannot insert image: ' + OpenDialog1.filename + '.', mtError, [mbOK], 0);
        end;
    end;
end;

The image is inserted using the ImageInsert method.