|
-
Apr 26th, 2006, 11:53 AM
#1
Thread Starter
Member
How do you put an image inside a richtextbox?
Is it possible to add an image inside a richtextbox so that it is visible within the interface and also printable?
Where would I start?
What I am looking to do is fill in text boxes and combo boxes on one side of my form while a richtextbox displays the information on the rightside of my form. Bascially the user is entering in data and a "print preview" invoice is being generated on the right side. The image I want to place in the RTB is my company's logo. Of course this image must print with the rest of the invoice.
Thanks!
- Dan
-
Apr 26th, 2006, 12:19 PM
#2
Re: How do you put an image inside a richtextbox?
this is how i did it.. there might be a better way
put your logo in an image control... hide it if u want..
VB Code:
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 Command1_Click()
Clipboard.Clear
Clipboard.SetData Image1.Image
SendMessage RTB1.hWnd, WM_PASTE, 0, 0
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 26th, 2006, 12:21 PM
#3
Re: How do you put an image inside a richtextbox?
There are atleast 3 methods. But this one may be the easiest.
-
Apr 26th, 2006, 12:36 PM
#4
Re: How do you put an image inside a richtextbox?
I win
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 26th, 2006, 12:43 PM
#5
Re: How do you put an image inside a richtextbox?
 Originally Posted by Static
I win 
Well done ! 
Have a lollypop.
-
Apr 26th, 2006, 02:29 PM
#6
Thread Starter
Member
Re: How do you put an image inside a richtextbox?
Thanks guys for your help. I appreciate it very much! I want the logo to be present on formload...That is why I call it in the formload event, obviously...lol Other than that I think I'm pretty much following your examples...Aren't I?
This code works as far as inserting the image into the RTB, however, when I print the RTB, the image is not printed. Help is appreciated...
Another thing, I'd like to be able to LOCK the RTB so the data can not be altered, other than with the Textboxes and combo boxes, however, when I lock it, the image doesn't show...Odd...
VB Code:
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 PlaceLogo()
Clipboard.Clear
Clipboard.SetData Image1.Picture
SendMessage RTBLog.hWnd, WM_PASTE, 0, 0
End Sub
Private Sub Form_Load()
Call PlaceLogo
End Sub
Private Sub CmdPrintRecord_Click()
Printer.Print frmmain.rTxtLog.Text
Printer.EndDoc
End Sub
-
Apr 26th, 2006, 02:45 PM
#7
Re: How do you put an image inside a richtextbox?
well. Lock it.. but
Do this
RTB1.Locked = False
'add image
RTB1.Locked = True
not sure about printing though.....
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 26th, 2006, 04:25 PM
#8
Thread Starter
Member
Re: How do you put an image inside a richtextbox?
Geeeze! Now why didn't I think of that? Thatnks Static!!
Every find yourself overlooking the obvious for something less obvious? Seems to be the case here...There it is, staring me in the face...You're right, Lock it!
Thanks again...
Now, onto this printing issue...I gotta print that image...Anyone? Ideas?
- Dan
-
Apr 26th, 2006, 05:18 PM
#9
Re: How do you put an image inside a richtextbox?
I haven't played with printing images from rtb, but one thought is that you can load the rtf into word and print from there.
You can use the Word Object from VB to do this.
-
Apr 26th, 2006, 10:17 PM
#10
Re: How do you put an image inside a richtextbox?
Printing:
There is a SelPrint method. It can print RTB contents with images.
But it is not very good. Seach MSDN, there is a code to print RTB contents.
Form_Load:
If the image is always same, you can save it in a rtf file. Then you can add it in the rtb during design time, or you can use the LoadFile method at Form_Load.
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
|