[ActiveX] Does not work event-loop inside of axserver
-
Hi all.
I have a task to create AxServer in the form of dll which will be used by the some native Windows system client.
But I have a problem where Qt event-loop doesn't work for successor of the QAxBindable class;
e.g. the QTimer event do not comes..@
class QTimer;
class ControlEngine : public QWidget, public QAxBindable
{
Q_OBJECT
public:
ControlEngine::ControlEngine(QWidget *parent)
: QWidget(parent)
, timer(new QTimer(this))
{
qDebug() << Q_FUNC_INFO;connect(timer, SIGNAL(timeout()), this, SLOT(timeout())); timer->start(1000); } ControlEngine::~ControlEngine() { qDebug() << Q_FUNC_INFO; } QAxAggregated *ControlEngine::createAggregate() { qDebug() << Q_FUNC_INFO; return new ProviderImpl(); }
private slots:
void timeout()
{
qDebug() << Q_FUNC_INFO;
}private:
QPointer<QTimer> timer;
};QAXFACTORY_DEFAULT(
ControlEngine,
"{FCF395FC-B5AB-40A9-B632-09693DF21D86}",
"{7595D4E0-E01B-4CC1-B330-60CEB6463C32}",
"{23036F7F-A62E-4169-8B38-5E8D27BEE44F}",
"{B4E43B7C-8473-4849-898C-7DC81DAE656B}",
"{CEF5A233-1EDF-41E8-B6AC-B6888116A80A}"
)
@Further, I correctly register the server in the Registry (it really so).
And to make some steps to launch of the "native" Windows client to use of my dll-server.From the "DebugView ":http://technet.microsoft.com/en-us/sysinternals/bb896647.aspxutility I see that all
COM-interfaces works successfully:- ControlEngine::ControlEngine(class QWidget *)
- ControlEngine::createAggregate(void)
- ProviderImpl::ProviderImpl(void)
- ProviderImpl::queryInterface(const class QUuid &,void **) , iid: QUuid("{d27c3481-5a1c-45b2-8aaa-c20ebbe8229e}")
- ProviderImpl::queryInterface(const class QUuid &,void **) , iid: QUuid("{d27c3481-5a1c-45b2-8aaa-c20ebbe8229e}")
- ProviderImpl::SetUsageScenario(enum _CREDENTIAL_PROVIDER_USAGE_SCENARIO,unsigned long) , scenario 2
- ProviderImpl::Advise(struct ICredentialProviderEvents *,__w64 unsigned int)
- ProviderImpl::UnAdvise(void)
- ProviderImpl::GetCredentialCount(unsigned long *,unsigned long *,int *)
- ProviderImpl::GetCredentialAt(unsigned long,struct ICredentialProviderCredential **)
- ProviderImpl::QueryInterface(const struct _GUID &,void **) , iid: QUuid("{63913a93-40c1-481a-818d-4072ff8c70cc}")
- ProviderImpl::GetFieldDescriptorCount(unsigned long *)
- ProviderImpl::GetFieldDescriptorAt(unsigned long,struct _CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR **)
- CredentialImpl::GetStringValue(unsigned long,wchar_t **)
- CredentialImpl::GetFieldState(unsigned long,enum _CREDENTIAL_PROVIDER_FIELD_STATE *,enum _CREDENTIAL_PROVIDER_FIELD_INTERACTIVE_STATE *)
BUT! I don't see the logs from the QTimer signal/slots.. What happens? How to fix it?
BR,
Denis -
I'm find out a some solution. Need to install an additional hook on WH_GETMESSAGE, where in their callback do qApp->processEvents().
@
static LRESULT QT_WIN_CALLBACK msgHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (qApp)
qApp->processEvents();
return ::CallNextHookEx(msg_hook, nCode, wParam, lParam);
}ControlEngine::ControlEngine(QWidget *parent)
: QWidget(parent)
, timer(new QTimer(this))
{
qDebug() << Q_FUNC_INFO;msg_hook = ::SetWindowsHookEx(WH_GETMESSAGE, msgHookProc, 0, ::GetCurrentThreadId()); qDebug() << Q_FUNC_INFO << "msg_hook" << msg_hook; QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timeout())); timer->start(1000);
}
ControlEngine::~ControlEngine()
{
if (msg_hook)
::UnhookWindowsHookEx(msg_hook);qDebug() << Q_FUNC_INFO;
}
@The interesting moment that in ActiveQt also present a hook on WH_GETMESSAGE. But there in callback twitches the qApp->sendPostedEvents().
Thus, it seems it is necessary to have two Hook. I don't know as it works - but it works. :)