Inserting an Image

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

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

[Visual Basic 6]
Private Sub mnuImage_Insert_Click()
    On Error GoTo err_InsertImage

    CmDialog1.DialogTitle = "Insert Image"
    CmDialog1.Filter = TXTextControl1.ImageFilters
    CmDialog1.FileName = ""
    CmDialog1.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt Or cdlOFNHideReadOnly
    CmDialog1.CancelError = True
    CmDialog1.ShowOpen

    TXTextControl1.ImageInsert CmDialog1.FileName, -1, 1, 0, 0, 100, 100, 3, 100, 100, 100, 100
    Exit Sub

err_InsertImage:
    If Err <> cdlCancel Then MsgBox Err.Description

End Sub

The image is inserted using the ImageInsert method.