|
-
Jul 29th, 2002, 10:34 PM
#1
Thread Starter
PowerPoster
Show Images in RichText Box?
I need to be able to insert a picture into a RichText Box. Is it possible?
-
Jul 29th, 2002, 10:58 PM
#2
-
Jul 29th, 2002, 11:05 PM
#3
Need-a-life Member
-
Jul 29th, 2002, 11:13 PM
#4
Thread Starter
PowerPoster
Umm... doesn't work.
I added the components Richtext Box and Windows Common Controls and I get my first error on
Form_Load
RTB.TextRTf
-
Jul 29th, 2002, 11:16 PM
#5
-
Jul 29th, 2002, 11:17 PM
#6
Need-a-life Member
-
Jul 29th, 2002, 11:18 PM
#7
Thread Starter
PowerPoster
lol
Sorry I forgot the most important part.
Method or Data Member Not Found
I'm guessing you haven't done whatever it is that you have to do to make the Picture box think its a Rich TextBox
-
Jul 29th, 2002, 11:21 PM
#8
Thread Starter
PowerPoster
What controls are meant to be on the form??
Cause you didn't inlucde the Project file so....
-
Jul 29th, 2002, 11:23 PM
#9
-
Jul 29th, 2002, 11:30 PM
#10
Thread Starter
PowerPoster
Aah works perfectly!!!
Thanks a million
-
Jul 29th, 2002, 11:32 PM
#11
-
Jul 29th, 2002, 11:37 PM
#12
Thread Starter
PowerPoster
Ohh.... I'm using the following code to send a picture to it
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
RTB.Text = RTB.Text + "<(BugFix)>"
PasteImages
End If
End Sub
But it takes the Image which is already there any moves it to the new postion. Is it possible to have multiple images?
-
Jul 29th, 2002, 11:39 PM
#13
-
Jul 29th, 2002, 11:42 PM
#14
-
Jul 29th, 2002, 11:44 PM
#15
Need-a-life Member
Try this:
VB Code:
Option Explicit
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
Private Sub Form_Load()
RTB.TextRTF = "This image <(BugFix)> is a BugFix"
PasteImages
End Sub
Private Function ParseFirst(Text As String, lStart As Long, lStop As Long) As String
ParseFirst = ""
lStart = InStr(Text, "<(")
If lStart Then
lStop = InStr(lStart, Text, ")>")
ParseFirst = Mid$(Text, lStart + 2, lStop - lStart - 2)
End If
End Function
Private Sub PasteImages()
Dim i As Integer
Dim e0 As String
Dim lStart As Long, lStop As Long
RTB.Tag = RTB.Text
Do
e0 = ParseFirst(RTB.Text, lStart, lStop)
If e0 = "" Then Exit Do
'clear clipboard of any data
Clipboard.Clear
'save pic to clipboard
Clipboard.SetData ImgLst.ListImages(e0).Picture, vbCFBitmap
Do Until RTB.Find("<(" & e0 & ")>") = -1
RTB.Locked = False
RTB.SelStart = RTB.Find("<(" & e0 & ")>")
RTB.SelLength = Len("<(" & e0 & ")>")
SendMessage RTB.hwnd, WM_PASTE, 0, 0
RTB.Locked = True
Loop
Loop
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
RTB.TextRTF = RTB.Tag + "<(BugFix)>"
PasteImages
End If
End Sub
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jul 29th, 2002, 11:53 PM
#16
Thread Starter
PowerPoster
Ok.... have u tried it with heaps of pictures.... it gets abit weird.
I removes the icons from the screen and then redoes them... so you can see the <(BugFix)> Text. Scrolling works fine... but everytime the user enters some thing
An example might be holding Enter in the above example.
I'm guessing its not possible to fix this.
-
Jul 29th, 2002, 11:56 PM
#17
-
Jul 30th, 2002, 12:02 AM
#18
Thread Starter
PowerPoster
Oh ok 
I'm running a Cel 1.1.
Its because your clearing the text and reinserting the pictures
The problem is is that I have to run this on a P110
Hopefully it'll be usable.
-
Jul 30th, 2002, 12:08 AM
#19
Thread Starter
PowerPoster
I've replaced the Bitmap with a Gif and I get an error on,
VB Code:
Clipboard.SetData ImgLst.ListImages(e0).Picture, vbCFBitmap
What do I need to change it 2? I had a look under help and it didn't show me anything to useful.
Should I just convert the Gifs to Bitmaps?
-
Jul 30th, 2002, 12:54 AM
#20
Thread Starter
PowerPoster
Come on Guys, nearly done!!
-
Jul 30th, 2002, 02:54 AM
#21
Thread Starter
PowerPoster
Ok... I tried to put this in my Chat Program, and I got an error when I try to insert a Gif or Bmp instead the image that you included in the Image List.
Urgh what do I need to change???
Heres the my Project is you guys are feeling really helpful.
http://www.vbforums.com/showthread.p...hreadid=188577
-
Jul 30th, 2002, 03:11 AM
#22
Thread Starter
PowerPoster
Ok, I've gotten rid of the Image List, so now I'm just using a Picture Box.
Now the Problem is that its possible to resize the picture
Is it possible to change this?
-
Jul 30th, 2002, 04:25 AM
#23
Addicted Member
Are you talking about the Autosize property?
-
Jul 30th, 2002, 09:00 PM
#24
Thread Starter
PowerPoster
No...
When the image is pasted into the RichtextBox, the user can resize it, which is not good.
Also, how can be able handle more than one picture? (like what do I need to change in the parser?
Thanks in Advance.
-
Aug 1st, 2002, 12:24 AM
#25
Thread Starter
PowerPoster
-
Aug 1st, 2002, 03:08 AM
#26
ok i had the same problem with "resizability". The only way i was able to get around this was to prevent people from highlighting the text. Whenever they would onmousedown or onmouseup, i would set the selection length to zero. This prevents resizing.
-
Aug 2nd, 2002, 02:43 AM
#27
Thread Starter
PowerPoster
Yeah... good idea.
But how can I allow for more than one picture?? Just create multiple parsers??
Thanks in Advance.
-
Aug 2nd, 2002, 03:03 AM
#28
i had them in the onmousedown and onmouseup properties of the richtextbox. However, it prevente highlighting ANY text.
-
Aug 2nd, 2002, 03:50 AM
#29
Thread Starter
PowerPoster
For what I want to use it for, locking it is fine.... can't believe that I didn't think of that early. 
But now all I need is the above code being able to handle mutliple pictures.
Its easier to replace the imagelist with picture boxs I found.... if anyone cares.
-
Aug 3rd, 2002, 02:23 AM
#30
Thread Starter
PowerPoster
Yet another *--------BuMp--------*
-
Aug 3rd, 2002, 02:46 AM
#31
Thread Starter
PowerPoster
Noone...?? Surely it can't be that hard.....
-
Aug 3rd, 2002, 02:50 AM
#32
Need-a-life Member
I guess, you can paste it anywhere... the secret are in these lines:
VB Code:
RTB.SelStart = RTB.Find("<(" & e0 & ")>")
RTB.SelLength = Len("<(" & e0 & ")>")
SendMessage RTB.hwnd, WM_PASTE, 0, 0
You have to select the place where you want to place your image, and paste it
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 10th, 2005, 05:12 PM
#33
Addicted Member
Re: Show Images in RichText Box?
I reallize that this thread is very old but i was wondering if somthign can be changed with this solution? This code processes all the richtextbox text and then researches it to replace the given strings with an image by paisting. What i was wondering is if you can make this process only the text between the last 2 vbCrLf and still keep the original text and images before these 2 vbCrLf
Any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|