CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014

    Unhappy select and insirt picture in RichTextBox

    i have a rich textbox and it contain a text, and i need to select the last line automatically by code. and i need to put a picture in the last line.
    any idea to help me.

    i use the below code :-

    PHP Code:
    ' in module 
    Option Explicit
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
        ByVal wMsg As Long, ByVal wParm As Long, IParam As Any) As Long
        Public Const WM_PASTE = &H302
        Private Const EM_GETLINECOUNT = &HBA

    in button

    Dim LineCount 
    As Long
    .SetData Image1.Picture
    SendMessage RichTextBox1
    .hwndWM_PASTE0&, 0
    this code is work but the picture come in the top( before text)

    and i need to put it after the last line of text.

    many thanks.

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: select and insirt picture in RichTextBox

    Create a .RTF MASTER with the picturebox and other placeholders. Then, it's easy to find/replace and insert images INTO the picturebox on the RTF that has it where it should be.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.