CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2000
    Location
    Leeds, UK
    Posts
    1

    Rich Text Control (RTF)


    "mypic.bmp" is a bitmap file. rtfMyText is a rich text box. It is filled with text. I do this:

    x = rtfMyText.SelStart
    rtfMyText.InsertOleObjectAt x, "myPic.bmp"

    but alas the picture is not inserted into the rich text box after all. Indeed I don't even know andcannot find out how to insert a string in the box:

    x = rtfMyText.SelStart
    rtfMyText.InsertStringAt x, "Hello world!"

    Anyone have any ideas on this?

    Thanks,

    Peter


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Rich Text Control (RTF)

    For "InsertStringAt" , you can use

    .SelText = NewTextString
    To insert ole objects, i am checking how to do. will post it here, if i can find.

    RK

  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Rich Text Control (RTF)

    This thing works for inserting the bmp pictures into RTB. Check it out:

    Take one form. put one RTB.
    Change the szfilename to valid file on your system and run

    option Explicit

    private Sub Form_Click()
    RichTextBox1.SelStart = 3
    RichTextBox1.SelText = "[new hi there]"
    End Sub

    private Sub Form_DblClick()
    Dim lpobj as OLEObject
    Dim szfilename as string
    szfilename = App.Path & "\ttt444.bmp" ' put some valid file name here
    set lpobj = RichTextBox1.OLEObjects.Add(, , szfilename)
    lpobj.DisplayType = rtfDisplayContent
    ' if you un comment the following line you will go to edit mode:
    'lpobj.DoVerb
    End Sub

    private Sub Form_Load()
    me.RichTextBox1.Text = "Hi there"
    End Sub





    RK

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured