[RESOLVED] richtextbox + vb6 + picture-VBForums
Results 1 to 20 of 20

Thread: [RESOLVED] richtextbox + vb6 + picture

  1. #1

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    Resolved [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)

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,573

    Re: richtextbox + vb6 + picture

    Welcome to the forums...

    Check this one: http://www.vbforums.com/showthread.p...39#post2131039

    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, VB6, Photoshop...

  3. #3

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    Re: richtextbox + vb6 + picture

    hello
    thank you, I have already seen this link but this code to reload all RTFTEXT.
    then moves scrolbar

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,573

    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, VB6, Photoshop...

  5. #5

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    Re: richtextbox + vb6 + picture

    thank you for your help
    No there is no difference
    should not use SelStart

  6. #6

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    Re: richtextbox + vb6 + picture

    help me please
    I block
    thank you for advance

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,960

    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

  8. #8

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,960

    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

  10. #10

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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"

  11. #11

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    Re: richtextbox + vb6 + picture

    hi
    i find this code in another site
    mais he can help you but he is in frech

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,960

    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

  13. #13

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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

  14. #14

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,960

    Re: richtextbox + vb6 + picture

    i think that is impossible to replace text with pictutre
    you think?

    i tested
    vb Code:
    1. Private Sub Command1_Click()
    2.     Clipboard.SetData Picture1.Image
    3.     t = "text"
    4.     s = rtb.SelStart
    5.     rtb.Find t
    6.     If Not rtb.SelStart = s Then
    7.         SendMessage rtb.hWnd, WM_PASTE, 0, 0
    8.         rtb.SelStart = s
    9.     End If
    10. 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:
    1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    2.                              hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    3.                              lParam As Any) As Long
    4.     Private Const WM_PASTE = &H302
    5.     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

  16. #16

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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)

  17. #17
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,409

    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.

  18. #18

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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

  19. #19
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,409

    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.

  20. #20

    Thread Starter
    Lively Member claiyah's Avatar
    Join Date
    Apr 2010
    Location
    Tunisia
    Posts
    79

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.