Use ActiveX in invisible C++Builder application

134 Views Asked by At

I'm working on a C++Builder application that uses an ActiveX control to perform some background work. If I run the app visibly, it works fine. But when when I run it invisibly (done by setting Application->ShowMainForm = false during startup), the ActiveX control does not behave the same. ActiveX methods that return immediately work fine, but a method that does background work does not work, no progress is made.

What can be done to make ActiveX controls behave normally, and let them perform background tasks, when the application is invisible?

As a test, I have created a small C# .NET project in Visual Studio, and there the same ActiveX control works fine in invisible mode (but not in C++Builder).

1

There are 1 best solutions below

0
On

Calling HandleNeeded() on the ActiveX control in the form constructor fixed the problem.

TForm1::TForm1()
{
    control1->HandleNeeded();
}

Apparently, some ActiveX controls need a window handle to function properly, and this handle is not created automatically when it is hidden.