Results 1 to 5 of 5

Thread: Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an ocx?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Question Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an ocx?

    Hello!

    I need to use the WinForms RichTextBox in VB6.

    Therefore I need to wrap it as COM control.

    Would anybody be willing to write me a first sample with 2 properties and 2 methods as a starting point?

    This way I could see how it's done and do the rest myself.

    This would be so helpful!

    Thak you very much for a reply!

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an oc

    Why would you need to use the RTB from .NET when VB6 has one of it's own?

    You're just adding more complexity and layers that will probably get you into more trouble than it's worth.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Re: Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an oc

    Because of Unicode.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an oc

    The VB6 guys here have an impressive body of work that includes many different types of Unicode controls.

    While I can certainly help with this, I think there are good reasons not to pursue this approach. For one thing, if you wrap a .Net Control for use in a VB6 application, you will not be able to site it on a VB6 ThunderForm. WinForms and VB6's UI engine are fundamentally incompatible. The only way to use it properly would be to export an entire .Net Form with the Control which would work well in VB6. I actually showed how to do just that in this CodeBank post.

    The other reason I recommend against this is because using COM interop adds the extra responsibility of making sure you have the correct framework installed. VB6 would already require you to register COM components for use and now .Net will just add this extra requirement. I like COM interop only as a last resort and there are many things in .Net that are not easily available in VB6 that would warrant using COM interop, I just don't think this is such a situation.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: Can anybody write me a COM wrapper for RichTextBox (Winforms) to be used as an oc

    Quote Originally Posted by Niya View Post
    The VB6 guys here have an impressive body of work that includes many different types of Unicode controls.
    Yeah, just use Kr00l's Unicode compatible RTB.

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