Results 1 to 6 of 6

Thread: Inserting Picture

  1. #1

    Thread Starter
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Hi,
    Could anyone please tell me how can i insert images into a Rich Text Box.

    Thanks in advance.

  2. #2
    New Member
    Join Date
    Jan 2001
    Location
    In the Europe black hole
    Posts
    10
    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

  3. #3
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    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
    Donald Sy - VB (ab)user

  4. #4
    Lively Member
    Join Date
    Jan 2007
    Posts
    97

    Re: Inserting Picture

    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???

  5. #5
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: Inserting Picture

    Quote Originally Posted by BorisAro
    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.
    God put me on this earth to do many great things, and I'm so far behind that I'm going to live forever.

    I'm programming for Windows using a Apple Mac Mini, 1.5Ghz with 512MB DDR RAM. I feel like I'm committing a crime :P

  6. #6
    Lively Member
    Join Date
    Jan 2007
    Posts
    97

    Re: Inserting Picture

    Thank You. My major problem - how to get from mdg Ole object file .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width