Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Using Clip Board to Paste 2 Images into a rich text box in VB6


Using Clip Board to Paste 2 Images into a rich text box in VB6

Author
Message
Slatibartfast
Slatibartfast
Forum God
Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)Forum God (908 reputation)

Group: Forum Members
Posts: 8, Visits: 1

Hello I am trying to inset insert 2 images in to rich text box, this is what I have tried:

 

Using OLE:

RichTextBox1.OLEObjects.Add , ,  strPicDestination

But the problem with this method is that it places a thumbnail into the text box and opens the image up with MS paint

Also I cant control the location of where the image is inserted

 

Then someone recommended me to use windows API in user32.dll you have SendMessageA that allows you to paste the image into rich text box from a clip board

You can find the exact syntax of how I am doing that here:

 

http://www.vbexplorer.com/VBExplorer/q&aform.asp

 

Anyways my problem is:

 

When I try to paste more then one image this way, the previous image gets replaced by the new images, so that I have only 1 images in a rich text box at all times.

 

I am not sure what is the cause of this could anyone think of why this happens

 

THANK YOU

 

PS

This is the syntax in a more confusing way if the link doesn’t work

 

Option Explicit 
 
Private Const WM_PASTE = &H302
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 Sub Form_Load()
  RichTextBox1.Text = "hi, hello, how are you doing ?"
End Sub
 
Private Sub Form_Resize()
  With Command1
    RichTextBox1.Move 0, 0, ScaleWidth, ScaleHeight - .Height
    .Move 0, ScaleHeight - .Height, ScaleWidth
  End With 'Command1
End Sub
 
Private Sub Command1_Click()
  Dim lngStart As Long
  Dim strFind As String
  Clipboard.Clear
  Clipboard.SetData LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\Assorted\BALLOON.BMP")
  strFind = "hello,"
  With RichTextBox1
    lngStart = Instr(.Text, strFind)
    .Text = Left$(.Text, lngStart - 1) & Mid$(.Text, lngStart + Len(strFind))
    .SelStart = lngStart - 1
    SendMessage .hwnd, WM_PASTE, 0, 0
  End With 'RichTextBox1
End Sub

 


Mark
Mark
Forum God
Forum God (141K reputation)

Group: Moderators
Posts: 1.1K, Visits: 11K

The problem is this line
.SelStart = lngStart - 1

This is placing the cursor before the word hello everytime before doing the paste operation. You will need to change the value of lngStart before pasting the second image.


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search