Results 1 to 4 of 4

Thread: VB6 - RTBCompose RTF Editor UserControl

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    VB6 - RTBCompose RTF Editor UserControl

    Sometimes you want to provide a RichTextBox control wrapped with some buttons and logic to let the user interact with it as a somewht fuller-featured editor for RTF data. This is easy enough but a little tedious to do over and over again.

    RTBCompose is a UserControl for this which you can add to your Projects and drop into your Forms. It helps keep the fiddly button handling logic out of your Forms and away from your business logic.

    Uses

    The attached demo is a small Project using RTBCompose to create a sort of stripped-down WordPad like program.

    A more practical use might be programs that let a user compose and send RTF messages. This is why the SendButton option exists in RTBCompose.

    You may also have a database that contains RTF-format Memo fields that you need users to be able to enter text into and/or edit existing text.

    What it adds

    RTBCompose provides a simple button bar supporting common rich editing operations such as cut, copy, paste, bold, etc.

    It also adds a font/color "picker" based on the Font Common Dialog (ChooseFont API) wrapped in a way that makes it "work like" the VB6 CommonDialog control.

    And it also has a button for "insert picture."

    It adds Ctrl-B, Ctrl-I, and Ctrl-U keystrokes in addition to the Ctrl-C, Ctrl-V, and Ctrl-X natively supported by the RichTextBox control. Users get used to these in other programs and get to expect them.

    There are other misc. features such as a left-right Margins property, a SendClicked event linked to the Send button you may not need, an IsDirty property and IsDirtyChanged event useful for adjusting things like menu item enabled status in the parent Form and detecting unsaved changes.

    What it subtracts

    RTBCompose only exposes a few things like the RichTextBox's base Font, Text, and RTFText properties and the LoadFile and SaveFile methods. It already takes care of most of the Selxxx properties with its own code, so you generally would not need them in the parent Form.

    Since you have the full source you could expose more properties, add or remove buttons, implement drag/drop, etc. as required.

    System Requirements

    Should pretty much work on any system that VB6 programs run on.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by dilettante; Apr 4th, 2013 at 01:26 PM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 - RTBCompose RTF Editor UserControl

    To answer a PMed question:


    You are right, there is nothing tricky or special or exotic here. RTBCompose just bundles up several very commonly used things into a quick drop-in package for generic use to save time when you want a few extras like a button bar to make editing easier for your users without writing the code over and over again.

    You might use it as is, or change it so that it meets your own needs. You can add or remove buttons, change the icons, etc. Then you have it handy to add to your future programs.


    The demo Project is just that: a demo. It is not intended to replace Wordpad or be useful in itself, but just to show how to use RTBCompose.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 - RTBCompose RTF Editor UserControl

    Here's a version that is the same as the previous but adds Clipboard monitoring in order to control the state of cmdPaste.Enabled.

    Whether this small extra functionality is a useful trade for the added amount of code is up to you.
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    34

    Re: VB6 - RTBCompose RTF Editor UserControl

    Thanks ! Nice except the Subclasser is not safe. Locks up easily while looking around in the IDE.

Tags for this Thread

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