Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can I create an instance of my control with Visual Basics CreateObject function?

0
Posted

Can I create an instance of my control with Visual Basics CreateObject function?

0

Visual Basic’s CreateObject function creates an instance of an OLE automation server. It uses the standard COM APIs to create the instance and then query for the server’s IDispatch. OLE controls are automation servers, however, they also implement a number of other OLE interfaces, and really expect to be active within a container. The primary difference between a standard automation server and an OLE control is that the control natively supports events and provides a persistence mechanism for its properties (through its container). So, by default a control expects to have a control site containing various interfaces, but CreateObject cannot provide these. COleControl does, however, provide a way for a control to behave as just an automation controller. All you have to do is override COleControl::IsInvokeAllowed and return TRUE. This will allow you to CreateObject on your control, although you must be sure that everything will still work without any persistence support. You can check fo

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123