N
none
Hello All
My app requires runtime creation of an ActiveX control on demand. I
attempted to fullfil this requirment with the following code snippet:
..
..
..
System::Type ^t =
System::Type::GetTypeFromProgID("CONTINUUMX.TRecordSetCtrl.1");
AxCONTINUUMXLib::AxTRecordSet ^rs =
(AxCONTINUUMXLib::AxTRecordSet^)System::Activator::CreateInstance(t);
rs->DataChange += gcnew
AxCONTINUUMXLib::_DTRecordSetEvents_DataChangeEventHandler(this,&Form1::OnDataChange);
rs->Open(textBox1->Text + "," + "Daily");
rs->Init(100, 0);
rs->GetRecDouble(0,0, val);
Unfortunately the above results in the following runtime error:
Unable to cast COM object of type 'AxCONTINUUMXLib.AxTRecordSet' to
class type ''. Instances of types that represent COM components cannot
be cast to types that do not represent COM components; however they can
be cast to interfaces as long as the underlying COM component supports
QueryInterface calls for the IID of the interface.
Is reflection and the use of System::Type::GetMethod the only (and
tedious) way of doing this?
Any hint or help is greatly appreciated.
Regards
My app requires runtime creation of an ActiveX control on demand. I
attempted to fullfil this requirment with the following code snippet:
..
..
..
System::Type ^t =
System::Type::GetTypeFromProgID("CONTINUUMX.TRecordSetCtrl.1");
AxCONTINUUMXLib::AxTRecordSet ^rs =
(AxCONTINUUMXLib::AxTRecordSet^)System::Activator::CreateInstance(t);
rs->DataChange += gcnew
AxCONTINUUMXLib::_DTRecordSetEvents_DataChangeEventHandler(this,&Form1::OnDataChange);
rs->Open(textBox1->Text + "," + "Daily");
rs->Init(100, 0);
rs->GetRecDouble(0,0, val);
Unfortunately the above results in the following runtime error:
Unable to cast COM object of type 'AxCONTINUUMXLib.AxTRecordSet' to
class type ''. Instances of types that represent COM components cannot
be cast to types that do not represent COM components; however they can
be cast to interfaces as long as the underlying COM component supports
QueryInterface calls for the IID of the interface.
Is reflection and the use of System::Type::GetMethod the only (and
tedious) way of doing this?
Any hint or help is greatly appreciated.
Regards