none
How to expose property of ocx built by C++(MFC) to be accessed from VB6 RRS feed

  • Question

  • I have a ocx code which was built by C++(MFC)

    I added a property to it.

    I want to access that property from VB6 but can't.

    I copied just ocx file.(there are lots of files are in the \Release folder including *.exp, *.lib, *.obj, *.tlb..

    Which files should I copy additionally to the VB6 application folder?

    Or what do I do to make it work?

    Wednesday, October 30, 2019 4:53 PM

Answers

  • Did you rebuild the project after adding the property?

    If you browse the type library embedded in the .ocx can you see the newly added property?

    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 3:49 PM
    Wednesday, October 30, 2019 7:35 PM
  • Hi Jeff0803,

    Thank you for posting here.

    According to your description, we recommend you could follow this doc to try to register the ocx file into your program. Then check if it could work.

    BTW, since this issue is more related to development with VB6 and ocx files, we also recommend you could redirect to VB6 forum or Neowin forum, where you could get better support.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 3:49 PM
    Thursday, October 31, 2019 4:49 AM
  • I found how to add propery from the "Add Property" and compiled.

    I copied *.ocx to the correct folder and now my VB6 program can see the property.

    However an error occur when access the property like following.

    Unexpected Error #440 
    Automation error
    ......
    Can you please give me any advice?


    I don't know anything about your .ocx or vB6 code.  So I suggest you do an internet search on the error codes/text that you have received.  Furthermore, since you are using VB6, you would probably benefit from posting and searching in forums devoted to old versions of VB -- http://www.vbforums.com/index.php
    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 8:37 PM
    Tuesday, November 5, 2019 8:26 PM

All replies

  • Did you rebuild the project after adding the property?

    If you browse the type library embedded in the .ocx can you see the newly added property?

    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 3:49 PM
    Wednesday, October 30, 2019 7:35 PM
  • Hi Jeff0803,

    Thank you for posting here.

    According to your description, we recommend you could follow this doc to try to register the ocx file into your program. Then check if it could work.

    BTW, since this issue is more related to development with VB6 and ocx files, we also recommend you could redirect to VB6 forum or Neowin forum, where you could get better support.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 3:49 PM
    Thursday, October 31, 2019 4:49 AM
  • How to browse the type library?

    Is there a tool to browse it?

    Where can I find that tool?

    Tuesday, November 5, 2019 4:10 PM
  • How to browse the type library?

    Is there a tool to browse it?

    Where can I find that tool?

    The Oleview.exe utility is one of the tools that come with the Windows SDK.
    Tuesday, November 5, 2019 4:15 PM
  • I can't see the new added property from the Oleview.exe > ITypeLibViewer

    (I loaded .ocx, is it correct? otherwise should I load tlb? I have no idea how to make the .tlb file)

    • Edited by Jeff0803 Tuesday, November 5, 2019 6:04 PM
    Tuesday, November 5, 2019 6:02 PM
  • I can't see the new added property from the Oleview.exe > ITypeLibViewer
    That would indicate to me that you may have added C++ code but you didn't update the project's idl/odl for the new property.
    Tuesday, November 5, 2019 6:05 PM

  • (I loaded .ocx, is it correct? otherwise should I load tlb? I have no idea how to make the .tlb file)

    The type library should be embedded in the .ocx.  If it wasn't, oleview would issue an error message when it opens the .ocx to load the type library.

    Typically, the type library (.tlb file) is created by the MIDL compiler when it processes the project's idl/odl file.  For a typical project, the .tlb is then embedded in the project output by the build process in the ordinary course .

    Tuesday, November 5, 2019 6:16 PM
  • I found how to add propery from the "Add Property" and compiled.

    I copied *.ocx to the correct folder and now my VB6 program can see the property.

    However an error occur when access the property like following.

    Unexpected Error #440 
    Automation error
    ......
    Can you please give me any advice?


    Tuesday, November 5, 2019 7:56 PM
  • I found how to add propery from the "Add Property" and compiled.

    I copied *.ocx to the correct folder and now my VB6 program can see the property.

    However an error occur when access the property like following.

    Unexpected Error #440 
    Automation error
    ......
    Can you please give me any advice?


    I don't know anything about your .ocx or vB6 code.  So I suggest you do an internet search on the error codes/text that you have received.  Furthermore, since you are using VB6, you would probably benefit from posting and searching in forums devoted to old versions of VB -- http://www.vbforums.com/index.php
    • Marked as answer by Jeff0803 Tuesday, November 5, 2019 8:37 PM
    Tuesday, November 5, 2019 8:26 PM
  • I'll do.

    Thanks!

    Tuesday, November 5, 2019 8:37 PM