I have a simple ActiveX control that have 4 properties and 8 methods Set and Get, the problem is that i can't access them at runtime , at desin time they works fine
below is the error message that occur when i lanch the programm in visual basic
and Dispatch map with file.idl of my ActiveX control.
In Visual C++ i have a message "member not found" when a access the propertys or methods.
Is anyone can help me with this problem.
Thanks in advance.
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Catastrophic failure (exception HRESULT: 0x8000FFFF (E_UNEXPECTED))
CSliderCtrl1.cpp File has dispatch map
BEGIN_DISPATCH_MAP(CSliderCtrl1, COleControl) DISP_PROPERTY_EX_ID(CSliderCtrl1, "backgroundColor", 1, GetbackgroundColor, SetbackgroundColor, VT_I4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "backColor", 2, GetbackColor, SetbackColor, VT_I4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "foreColor", 3, GetforeColor, SetforeColor, VT_I4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "positionBar", 4, GetpositionBar, SetpositionBar, VT_I4) END_DISPATCH_MAP()
Slider.idl File
[ uuid(F9248E73-F5AD-43B1-815B-91817E91B537), version(1.0), control ] library SliderLib { importlib(STDOLE_TLB);
// Primary dispatch interface for CSliderCtrl1
[ uuid(093C2CB6-C812-4B91-84CB-1C508439DBFD) ]
dispinterface _DSlider
{
properties:
[id(1)] COLORREF backgroundColor;
[id(2)] COLORREF backColor;
[id(3)] COLORREF foreColor;
[id(4)] unsigned long positionBar;
methods:
[id(5)] COLORREF GetbackgroundColor();
[id(6)] void SetbackgroundColor([in] COLORREF color );
[id(7)] COLORREF GetbackColor();
[id(8)] void SetbackColor([in] COLORREF color);
[id(9)] COLORREF GetforeColor();
[id(10)] void SetforeColor([in] COLORREF color);
[id(11)] unsigned long GetpositionBar();
[id(12)] void SetpositionBar([in] unsigned long position);
};
// Event dispatch interface for CSliderCtrl1
[ uuid(9113AA84-629F-4C34-88A3-EBFFF0F94B2E) ]
dispinterface _DSliderEvents
{
properties:
// Event interface has no properties
methods:
};
// Class information for CSliderCtrl1
[ uuid(FA933E84-1B30-4283-9A2A-9CC1E8D99408), control ]
coclass Slider
{
[default] dispinterface _DSlider;
[default, source] dispinterface _DSliderEvents;
};
};
Finally i found the way, the code in Visual Basic must be
Dim slider As New Object
slider = AxSlider1.GetOcx
slider.SetbackgroundColor(100000)
BEGIN_DISPATCH_MAP(CSliderCtrl1, COleControl) DISP_FUNCTION_ID(CSliderCtrl1, "GetbackgroundColor",1, GetbackgroundColor,VT_UI4,VTS_NONE) DISP_FUNCTION_ID(CSliderCtrl1, "SetbackgroundColor",2, SetbackgroundColor, VT_EMPTY,VTS_UI4 ) DISP_FUNCTION_ID(CSliderCtrl1, "GetbackColor",3, GetbackColor, VT_UI4, VTS_NONE) DISP_FUNCTION_ID(CSliderCtrl1, "SetbackColor", 4,SetbackColor, VT_EMPTY, VTS_UI4) DISP_FUNCTION_ID(CSliderCtrl1, "GetforeColor",5, GetforeColor,VT_UI4, VTS_NONE) DISP_FUNCTION_ID(CSliderCtrl1, "SetforeColor", 6,SetforeColor, VT_EMPTY, VTS_UI4) DISP_FUNCTION_ID(CSliderCtrl1, "GetPositionBar",7, GetPositionBar,VT_UI4, VTS_NONE) DISP_FUNCTION_ID(CSliderCtrl1, "SetPositionBar", 8,SetPositionBar, VT_EMPTY, VTS_UI4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "backgroundColor", dispidBackgroundColor, GetbackgroundColor, SetbackgroundColor, VT_UI4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "backColor", dispidBackColor, GetbackColor, SetbackColor, VT_UI4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "foreColor", dispidForeColor, GetforeColor, SetforeColor, VT_UI4) DISP_PROPERTY_EX_ID(CSliderCtrl1, "PositionBar", dispidPositionBar, GetPositionBar, SetPositionBar, VT_UI4) END_DISPATCH_MAP()
User contributions licensed under CC BY-SA 3.0