-
Apr 12th, 2010, 10:16 AM
#1
Thread Starter
Lively Member
[RESOLVED] richtextbox + vb6 + picture
hi all
is there a way to insert an image in a multiline RichTextBox in vb6 Inserting designated point without using SelStart ... (well, without moving the scrollbar)
-
Apr 13th, 2010, 01:11 AM
#2
Re: richtextbox + vb6 + picture
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Apr 13th, 2010, 08:21 AM
#3
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
hello
thank you, I have already seen this link but this code to reload all RTFTEXT.
then moves scrolbar
-
Apr 13th, 2010, 08:34 AM
#4
Re: richtextbox + vb6 + picture
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Apr 13th, 2010, 10:19 AM
#5
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
thank you for your help
No there is no difference
should not use SelStart
-
Apr 27th, 2010, 08:32 AM
#6
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
help me please
I block
thank you for advance
-
Apr 27th, 2010, 10:15 PM
#7
Re: richtextbox + vb6 + picture
i think you can only insert at the selection point, but easy to move back to previous position
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 28th, 2010, 05:49 AM
#8
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
hello
i think you can only insert at the selection point, but easy to move back to previous position
how can i move the picture after the insertion please ?
thx
-
Apr 28th, 2010, 07:12 AM
#9
Re: richtextbox + vb6 + picture
how do you know where you want the picture?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 28th, 2010, 08:15 AM
#10
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
I replace characters with images
therefore the position varies.
example: replace "all" in this text by picture1.picture "hi all" and in this text "hello all"
-
Apr 28th, 2010, 12:31 PM
#11
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
hi
i find this code in another site
mais he can help you but he is in frech
-
Apr 28th, 2010, 04:20 PM
#12
Re: richtextbox + vb6 + picture
you can use the find method of the richtext then replace the found text
how are you inserting the picture?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 29th, 2010, 03:25 AM
#13
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
how are you inserting the picture?
I was looking how to insert an image into desired insertion point.
Now I found how to insert an object into RichTextBox and I work on it
-
Apr 29th, 2010, 03:26 AM
#14
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
you can use the find method of the richtext then replace the found text
i think that is impossible to replace text with pictutre
-
Apr 29th, 2010, 04:02 AM
#15
Re: richtextbox + vb6 + picture
i think that is impossible to replace text with pictutre
you think?
i tested
vb Code:
Private Sub Command1_Click() Clipboard.SetData Picture1.Image t = "text" s = rtb.SelStart rtb.Find t If Not rtb.SelStart = s Then SendMessage rtb.hWnd, WM_PASTE, 0, 0 rtb.SelStart = s End If End Sub
where rtb is a richtextbox containing default text
you need the api declare for sendmessage
and some picture already in picture1
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 Const WM_COPY As Long = &H301
Last edited by westconn1; Apr 29th, 2010 at 04:20 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 29th, 2010, 07:47 AM
#16
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
thx for this code but you have'n see my question :
hi all
is there a way to insert an image in a multiline RichTextBox in vb6 Inserting designated point without using SelStart ... (well, without moving the scrollbar)
-
Apr 29th, 2010, 08:37 AM
#17
Re: richtextbox + vb6 + picture
You need to get the Scroll position before pasting and reset it later to previous position:
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 Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Const WM_USER = &H400
Private Const EM_GETSCROLLPOS = (WM_USER + 221)
Private Const EM_SETSCROLLPOS = (WM_USER + 222)
Private Const WM_PASTE = &H302
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub FindAndReplace(pText As String, pPic As Picture)
Dim tp As POINTAPI
Clipboard.Clear
Clipboard.SetData pPic
LockWindowUpdate rtb.hwnd 'Redrawing stops here
SendMessage rtb.hwnd, EM_GETSCROLLPOS, 0&, tp 'Get Scroll position before Finding
rtb.Find pText
SendMessage rtb.hwnd, WM_PASTE, 0, 0
SendMessage rtb.hwnd, EM_SETSCROLLPOS, 0&, tp 'Restore Scroll Position
LockWindowUpdate 0& 'Redraw again
End Sub
Private Sub Command1_Click()
FindAndReplace "123", Picture1.Image '(use your text and picture here)
End Sub
Last edited by jcis; Apr 29th, 2010 at 08:42 AM.
-
Apr 29th, 2010, 11:23 AM
#18
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
yes good idea but LockWindowUpdate refresh the desktop after using it no?
I use the insert image every second. its not slow down my program?
thank you for your reply
-
Apr 29th, 2010, 11:28 AM
#19
Re: richtextbox + vb6 + picture
LockWindowUpdate receives the Hwnd of the Window by parameter and it should affect only that Window. But it's not related to keeping the scrollbar in position, it's there only to avoid flickering so anyways maybe you don't need it, comment the LockWindowUpdate lines and see what happens, if the flickering level is admissible for you then you don't need it.
-
Apr 29th, 2010, 11:35 AM
#20
Thread Starter
Lively Member
Re: richtextbox + vb6 + picture
I think I should keep LockWindowUpdate because the text in which I insert images is too long so if I do not use it its going to be ugly lol
thank you very much for your help
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
|