Results 1 to 21 of 21

Thread: Shaded Box in RichTextBox

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Shaded Box in RichTextBox

    Does anyone know how to create a shaded box in a RichTextBox that would look like the one you see when something is quoted in a post?

    For example
    Quote Originally Posted by MartinLiss View Post
    Does anyone know how to create a shaded box in a RichTextBox that would look like the one you see when something is quoted in a post?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Shaded Box in RichTextBox

    See what you think of this. If it isn't the right shade, let me know and I'll play around some more
    Code:
    Private Sub Form_Load()
    RichTextBox1.BackColor = &HCECECE
    End Sub

  3. #3

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Sorry if I mislead you Hack but what I meant was that I wanted to reproduce the look of, for example, the entirety of post #1 in a richtextbox. In other words a shaded box within the RTB. It will take modifications to the RTB's TextRTF property and I've done a bunch of that in my Private Message Viewer (shameless plug), but so far I haven't been successful with the box. BTW if you or anyone else is interested here is the official RTF spec sheet.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Shaded Box in RichTextBox

    From that RTF spec sheet, it appears you will want to apply "paragraph borders"
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Shaded Box in RichTextBox

    Marty

    I have not worked with RichTextBoxes, but, is it possible
    to use the Line method in one?

    If so, perhaps you could set ForeColor to light gray, and use the BF
    parameters. There would be several tricky aspects to this:
    -- 1. getting the correct x,y coordinates
    -- 2. the shaded area would need to be "painted" before the text is added,
    or else the text would be "wiped out" by the fill.


    If that doesn't work, is it possible to embed a RichTextBox control
    in a RichTextBox? If so, the embedded controls could possibly be
    a control array (for multiple uses) -- would that do you any good?

    Spoo

  6. #6
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    Re: Shaded Box in RichTextBox

    hello, two suggestions, because you do not create a bitmap simulating an appointment, by graphical methods which would be much easier to create it.

    the second and the best, because it uses a webbrowser in replacement of the RichTextBox where you can work more freely.
    leandroascierto.com Visual Basic 6 projects

  7. #7

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by LaVolpe View Post
    From that RTF spec sheet, it appears you will want to apply "paragraph borders"
    Yes, but as they say, the devil is in the details.

  8. #8

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by LeandroA View Post
    hello, two suggestions, because you do not create a bitmap simulating an appointment, by graphical methods which would be much easier to create it.

    the second and the best, because it uses a webbrowser in replacement of the RichTextBox where you can work more freely.
    I hate working with TextRTF but my whole program is built around it so I'd like to stick with it exclusively.

  9. #9
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    Could you insert a table with one row one column: I can upload the rtb editor
    Attached Images Attached Images  
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  10. #10

  11. #11

  12. #12
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by MartinLiss View Post
    I just now found some code on the web by our member and rtf-wizard moeur, but upload what you have anyhow.
    Attached
    Attached Files Attached Files
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  13. #13

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by isnoend07 View Post
    Attached
    Thanks. It looks like someone took the four class modules written by moeur that I just found that deal with rtf and added other stuff.

  14. #14
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by MartinLiss View Post
    Thanks. It looks like someone took the four class modules written by moeur that I just found that deal with rtf and added other stuff.
    from the date i put on the folder, that would probably be me. i just added the table before i posted. The table i copied from my app. in my app it opens a form
    to display how many columns, centered and width options. i have noticed that typing into the table the text can run past the table borders and not contained within the table.
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  15. #15

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Oh how I hate richtext.

    I tried to modify the code so that I can set a row's height to 1000 twips using the \trrh row height parameter and as you see here the Debug.Print display of strInsert looks like

    {\colortbl ;\red221\green221\blue221;}
    \highlight1\par\trowd\trqc\trgaph10\trleft36\trrh1000\cellx8248\pard\intbl Originally Posted by MartinLiss\cell\row
    \pard
    \par
    but when strInsert is inserted into the rich text the result is

    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
    {\colortbl ;\red221\green221\blue221;}
    \viewkind4\uc1\pard\highlight1\f0\fs17
    \par \trowd\trgaph10\trleft36\trqc\cellx8248\pard\intbl Originally Posted by MartinLiss\cell\row
    \pard
    \par
    \par }
    Grrrrr.

  16. #16
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Shaded Box in RichTextBox

    Too bad you've gone so far using RTF markup already.

    The DHTMLEdit control in "browse mode" make a nice alternative document canvas. I prefer it to a WebBrowser control because you can use it for input as well in "edit mode." Like the difference between a Label and a TextBox.

    RTF itself just isn't as human-friendly as HTML + CSS even though they're both plain-text markup. HTML and CSS are well documented for the Trident rendering engine underlying most of Microsoft's HTML software - right in your MSDN Library. IE, MSHTML, WebBrowser control, and DHTMLEdit control all use the Trident engine.

  17. #17
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by MartinLiss View Post
    Oh how I hate richtext.

    I tried to modify the code so that I can set a row's height to 1000 twips using the \trrh row height parameter and as you see here the Debug.Print display of strInsert looks like



    but when strInsert is inserted into the rich text the result is



    Grrrrr.
    I have a module for line spacing i will upload it and maybe it will help. Don' remember why I have it. I have went a few rounds with rtb and quite a few times. I know what you mean
    Attached Files Attached Files
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  18. #18

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by isnoend07 View Post
    I have a module for line spacing i will upload it and maybe it will help. Don' remember why I have it. I have went a few rounds with rtb and quite a few times. I know what you mean
    I don't think that applies to me. I'm trying to to increase the height of a line (actually a table with one row and one column) rather than increasing the spacing between lines.

  19. #19
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    Quote Originally Posted by MartinLiss View Post
    I don't think that applies to me. I'm trying to to increase the height of a line (actually a table with one row and one column) rather than increasing the spacing between lines.
    Seems i remember the tables height is based on the height of text be used for that row
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  20. #20
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Shaded Box in RichTextBox

    i have verified the table matching the fonts height:
    Attached Images Attached Images  
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  21. #21

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Shaded Box in RichTextBox

    If what you say is true then why does the spec say this about \trrh?


    Height of a table row in twips. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.

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