3
votes

First, I need to clarify that this is NOT a VBA related question. This error is occurring on a release program of Visual Basic 6.0 that has nothing to do with MS Office.


The program in question consists of an executable called "Color_Picker.exe" and an ActiveX control called "ColorManagementControls.ocx". I am trying to make use of Registration-Free Activation of COM.

Whenever I try to run my program with the manifests setup

"Application-defined error or user-defined error."

pops up. From the title of the error window, which is always the name of the offending class, I can tell the error is happening within the OCX.

The issue is that I know class runs free of error. In order to make sure this wasn't an issue of incompatibility with Windows 10, since the program is being compiled in Windows XP, I properly registered my OCX, and when I do that the program runs smoothly. So I'm guessing that my OCX manifest is not properly set up or requires extra add-ons because I followed the MSDN tutorial to the letter.

EDIT: I forgot mentioning that this had previously worked when I tested it with an unfinished version of both the program and class. I then added some properties to the OCX and made some UI improvements to the EXE. That is when it stopped working.

This is the EXE manifest being used:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
  manifestVersion="1.0">
<assemblyIdentity
            type = "win32"
            name = "Color_Picker"
            version = "1.0.0.0" />
<dependency>
            <dependentAssembly>
                        <assemblyIdentity
                                    type="win32"
                                    name="ColorManagementControls.ocx"
                                    version="1.0.0.0" />
            </dependentAssembly>
</dependency>
</assembly>

This is the OCX manifest being used:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
  manifestVersion="1.0">

<assemblyIdentity
   type="win32"
   name="ColorManagementControls.ocx"
   version="1.0.0.0" />

<file name = "ColorManagementControls.ocx">

<comClass
    clsid="{F25E6EEC-9586-4606-B0F3-D3601F59CD33}"
    threadingModel = "Apartment" />

<typelib tlbid="{F24DF9F0-C974-4307-A096-3A006918FB86}"
       version="1.0" helpdir=""/>

</file>

<comInterfaceExternalProxyStub 
    name="_udcColorScroll" 
    iid="{18EBDF4B-F66A-422F-99AF-C968FE10F494}"
    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
    baseInterface="{00000000-0000-0000-C000-000000000046}"
    tlbid = "{F24DF9F0-C974-4307-A096-3A006918FB86}" />

</assembly>

And this is what the OLE/COM viewer shows about my OCX:

// Generated .IDL file (by the OLE/COM Object Viewer)
// 
// typelib filename: ColorManagementControls.ocx

[
  uuid(F24DF9F0-C974-4307-A096-3A006918FB86),
  version(2.0),
  helpstring("vbpColorManageControls")
]
library vbpColorManageControls
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    interface _udcColorScroll;
    dispinterface __udcColorScroll;

    [
      odl,
      uuid(18EBDF4B-F66A-422F-99AF-C968FE10F494),
      version(1.0),
      hidden,
      dual,
      nonextensible,
      oleautomation
    ]
    interface _udcColorScroll : IDispatch {
        [id(0x40030000), propget]
        HRESULT HideCursor([out, retval] VARIANT_BOOL* HideCursor);
        [id(0x40030000), propput]
        HRESULT HideCursor([in] VARIANT_BOOL HideCursor);
        [id(0x40030001), propget]
        HRESULT ClipOnClick([out, retval] VARIANT_BOOL* ClipOnClick);
        [id(0x40030001), propput]
        HRESULT ClipOnClick([in] VARIANT_BOOL ClipOnClick);
        [id(0x68030005), propget]
        HRESULT ColorOut([out, retval] OLE_COLOR* );
        [id(0x68030004), propget]
        HRESULT Value([out, retval] single* );
        [id(0x68030004), propput]
        HRESULT Value([in] single );
        [id(0x68030003), propget]
        HRESULT StartColor([out, retval] OLE_COLOR* );
        [id(0x68030003), propput]
        HRESULT StartColor([in] OLE_COLOR );
        [id(0x68030002), propget]
        HRESULT EndColor([out, retval] OLE_COLOR* );
        [id(0x68030002), propput]
        HRESULT EndColor([in] OLE_COLOR );
        [id(0x68030001), propget]
        HRESULT Orientation([out, retval] eColPickOrientation* );
        [id(0x68030001), propput]
        HRESULT Orientation([in] eColPickOrientation );
        [id(0x68030000), propget]
        HRESULT BorderStyle([out, retval] eColPickBorderStyle* );
        [id(0x68030000), propput]
        HRESULT BorderStyle([in] eColPickBorderStyle );
    };

    [
      uuid(F25E6EEC-9586-4606-B0F3-D3601F59CD33),
      version(1.0),
      noncreatable,
      control
    ]
    coclass udcColorScroll {
        [default] interface _udcColorScroll;
        [default, source] dispinterface __udcColorScroll;
    };

    [
      uuid(CE70501E-3905-4718-A1A9-FF3C844A8286),
      version(1.0),
      hidden,
      nonextensible
    ]
    dispinterface __udcColorScroll {
        properties:
        methods:
            [id(0x00000001)]
            void Change([in, out] tColorScll* hoverInf);
            [id(0x00000002)]
            void Scroll([in, out] tColorScll* hoverInf);
    };

    typedef [uuid(66A38F2E-D6C2-49D3-BD5B-EF68DF34CECE), version(1.0)]
    enum {
        CPB_NONE = 0,
        CPB_SINGLE = 1,
        CPB_SINGLESHADED = 2,
        CPB_DOUBLE = 3,
        CPB_DOUBLESHADED = 4
    } eColPickBorderStyle;

    typedef [uuid(206F68AB-F66C-4BD9-AD43-82355A403A4E), version(1.0)]
    enum {
        CPO_HORIZONTAL = 0,
        CPO_VERTICAL = 1
    } eColPickOrientation;

    typedef [uuid(746EB8A7-B27D-44AF-B179-AE862424BC6E), version(1.0)]
    struct tagtColorScll {
        [helpstring("ColorScroll")        
]
        OLE_COLOR ColorScroll;
        [helpstring("LocScroll")        
]
        single LocScroll;
    } tColorScll;
};
1

1 Answers

1
votes

Based on your comment that

this had previously worked when I tested it with an unfinished version of both the program and class. I then added some properties to the OCX and made some UI improvements to the EXE. That is when it stopped working.

it seems the problem must stem from some inconsistency between the compiled OCX and one or both of the manifest files.

From the code you have posted, the thing which stands out is that your OCX manifest has:

<typelib tlbid="{F24DF9F0-C974-4307-A096-3A006918FB86}"
       version="1.0" helpdir=""/>
                ^^^

but the IDL has version(2.0) for the same GUID. I would see if changing the manifest to get them in sync will fix this.