I am using a combination of the ATL and WTL for a project and have derived my own class from CWindowImpl
, which looks something like this:
class CMyControl : public CWindowImpl<CMyControl>
{
public:
DECLARE_WND_CLASS(_T("MyClassName"))
...
BEGIN_MSG_MAP(CMyControl)
...
END_MSG_MAP()
};
This is all good, and if I use CMyControl::Create
to create an instance of the control, then it works fine as under the hood, the CWindowImpl::Create
function will register the Win32 class (in this case called MyClassName
).
However, it is this behaviour - the Win32 class being registered when an instance is created - that is causing me a headache. I want to be able to register the class up-front so I can use the class name with another 3rd-party library that will create the window using the Win32 CreateWindowEx
call, but I can't find a simple way to do this. Currently I workaround this by using static
as the CreateWindowEx
class name and then use CMyWindow::SubclassWindow
to attach my class to it, but this is a kludge.
Does anyone know how to register a CWindowImpl
derived class without actually creating a window, so I can pass the class name to CreateWindowEx
successfully? I would of thought there was a standard way to do this with ATL windows as I can't be the first to come across this issue.