Hi,
Could anyone please tell me how can i insert images into a Rich Text Box.
Thanks in advance.
Printable View
Hi,
Could anyone please tell me how can i insert images into a Rich Text Box.
Thanks in advance.
Const WM_CUT = &H300
Const WM_COPY = &H301
Const WM_PASTE = &H302
Const WM_CLEAR = &H303
Const WM_UNDO = &H3040
Public 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 Sub mnuinsertimagine_Click()
On Error GoTo eroare
CommonDialog1.CancelError = True
With CommonDialog1
.DialogTitle = "Fisier imagine..."
.Filter = "Imagini: *.bmp;*jpg;*.gif;*.emf|*.bmp;*jpg;*.gif;*.emf"
.ShowOpen 'show the dialog box
Picture1.Picture = LoadPicture(.FileName)
End With
Clipboard.Clear
Clipboard.SetData Picture1.Picture
SendMessage rtb.hWnd, WM_PASTE, 0, 0
Exit Sub
eroare:
Err.Clear
Exit Sub
End Sub
This code snippet I had lying around might also help you:
Code:Option Explicit
Private Sub Form_Click()
RichTextBox1.SelStart = 3
RichTextBox1.SelText = "[new hi there]"
End Sub
Private Sub Form_DblClick()
Dim lpobj As OLEObject
Dim szfilename As String
szfilename = App.Path & "\ttt444.bmp" ' put some valid file name here
Set lpobj = RichTextBox1.OLEObjects.Add(, , szfilename)
lpobj.DisplayType = rtfDisplayContent
' if you un comment the following line you will go to edit mode:
'lpobj.DoVerb
End Sub
Private Sub Form_Load()
Me.RichTextBox1.Text = "Hi there"
End Sub
I got errors: (VS 2005)
Dim lpobj As OLEObject ----> not defined
Set lpobj = RichTextBox1.OLEObjects.Add(, , szfilename)----> OLEobjects is not a member of RichText...
Why???
You can use Miaourice's example, it will work. The only downside is you have to copy the image to the clipboard first, which is a pain. But I'm sure if you research it enough, there's a way around that.Quote:
Originally Posted by BorisAro
Thank You. My major problem - how to get from mdg Ole object file .