Here's a simple method to programmatically insert an image into a RichTextBox control, by copying it into the clipboard and then pasting it into the control: |
Click here to copy the following block | Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _ hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Const WM_PASTE = &H302
Sub InsertPictureInRichTextBox(RTB As RichTextBox, Picture As StdPicture) Clipboard.Clear Clipboard.SetData Picture SendMessage RTB.hwnd, WM_PASTE, 0, 0 End Sub |
You can load the picture from another control (a PictureBox, for example), or directly from a file using the LoadPicture function: |
|