I am trying to get the message loop from a ATL::CAppModule in my project, there seems to be none, so:
- I've tried defining CAppModule, with
extern CAppModule _Module;
in"stdafx.h"
andCAppModule _Module;
in my .cpp file, it compiles, linkes and at the perform registration step I get an assertion inatlbase.h
hereATLASSERT(_pAtlModule == NULL);
which means that the CAppModule has already been declared.
But I can't seem to find another CAppModule instantiation, instead I see a CAtlExeModuleT instantiation (it is not my code..).
now.. from what I've searched I haven t found a way to get the message loop from a CAtlExeModuleT object. Are they different things or am I missing something?
There is a mix of issues here.
CAppModule
is a WTL class._pAtlModule
is static/global ATL variable that points to module singleton class.You cannot fix ATL
_pAtlModule
problem with WTLCAppModule
because the two are unrelated (atlthough have certain similarity between).To fix the
_pAtlModule
problem you need an ATL module instance. The simplest is to addCComModule
static:Because
CComModule
itself is here for backward compatibility only, it would be the better to useCAtlExeModuleT
(and friends) instead, however WTL will not work this way because WTL'sCAppModule
inherits fromCComModule
. The global instance ofCAppModule
will also be the instance for ATLCComModule
:and then later on some application object:
the
GetMessageLoop
call will retrieve the message loop you added earlier.Having this ATL/WTL issue resolved, you can move on to the WTL message loop thing, where you expect
PreTranslateMessage
to be called on modal dialog message loop and it won't be called there because it is not expected to work this way (CMessageLoop
calls message filter chain, and modal dialog's loop don't).