CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    2

    How to create custom interop container controls

    Hi,

    I want to create my own custom control container in Vb.net 2008 to be used for vb6 application. Therefore, it should be an interop user control container which will be exposed to vb6 through interop tools. I am trying to create it but it behaves like a control not as a container.
    How can I add a control to it at design time ?
    What I have done, is to place a groupbox control on the usercontrol area.
    The groupbox is named as ContainerArea while the usercontrol itself is named as unicodeframe. here's the code:

    Code:
    Imports System.ComponentModel
    Imports System.ComponentModel.Design
    Imports System.Windows.Forms
    <Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design", GetType(IDesigner))> _
    <ComClass(UnicodeFrame.ClassId, UnicodeFrame.InterfaceId, UnicodeFrame.EventsId)> _
    Public Class UnicodeFrame
        Inherits UserControl
        Implements System.ComponentModel.INestedContainer
    
     Public Sub Add(ByVal component As System.ComponentModel.IComponent) Implements System.ComponentModel.IContainer.Add
    
            Me.Container.Add(component)
        End Sub
    
        Public Sub Add(ByVal component As System.ComponentModel.IComponent, ByVal name As String) Implements System.ComponentModel.IContainer.Add
            Me.Container.Add(component, name)
        End Sub
    
        Public ReadOnly Property Components1() As System.ComponentModel.ComponentCollection Implements System.ComponentModel.IContainer.Components
            Get
                Return Container.Components
            End Get
        End Property
    
        Public Sub Remove(ByVal component As System.ComponentModel.IComponent) Implements System.ComponentModel.IContainer.Remove
            Container.Remove(component)
        End Sub
    
        Public ReadOnly Property Owner() As System.ComponentModel.IComponent Implements System.ComponentModel.INestedContainer.Owner
            Get
                Return Me.ParentForm
            End Get
        End Property
    The control works ok on the vb.net testform but it does not work on the vb6 form as a container.

    Any help will be appreciated.

    kind regards,

    Nasir
    Last edited by 2kaud; September 7th, 2017 at 05:48 AM.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to create custom interop container controls

    [ Moved ]

  3. #3
    Join Date
    Sep 2017
    Posts
    2

    Re: How to create custom interop container controls

    Quote Originally Posted by HanneSThEGreaT View Post
    [ Moved ]
    Where was this moved too? I can't find it and have the same issue.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to create custom interop container controls

    It was moved to here - but has had no further posts. Sorry.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Sep 2017
    Posts
    2

    Re: How to create custom interop container controls

    Quote Originally Posted by 2kaud View Post
    It was moved to here - but has had no further posts. Sorry.
    I see, thanks.

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