Re: creating a light-weight CWnd-derived class
class CMyWnd : public CWnd
{
// Construction
public:
CMyWnd();
LRESULT Onxxxx (WPARAM wParam, LPARAM lParam);
};
// ----------------------------------------------------------
BEGIN_MESSAGE_MAP(CMyWnd, CWnd)
ON_MESSAGE ( WM_xxxx, Onxxxx )
END_MESSAGE_MAP()
CMyWnd::CMyWnd ()
{
}
LRESULT CMyWnd::Onxxxx(WPARAM wParam, LPARAM lParam)
{
//stuff
return 1;
}
// -----------------------------------------------------------
CMyWnd* m_pMyWnd = new CMyWnd ();
if ( ! m_pMyWnd->CreateEx (0, AfxRegisterWndClass(0), _T("Something"),
WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
{
// error
}
tfs wrote:
I would like to create a very light-weight, standalone, non-visible,
NULL-parented CWnd-derived class, without relying on any resource created in
.rc file (like CDialog which requires a dialog template). This light-weight
class is used as a private message and timer handler, with a HWND which can
be passed to, in my case, DirectShow API for event notifications; and in
general use, I can instantiate such class in anywhere and in any UI-thread
with ease.
I did consider deriving from CStatic, as the class is simple and small
enough. However, it requires a parent CWnd, i.e. it cannot be a standalone
CWnd object. I also considered CDialog, but it requires a dialog template as
described above. I even considered CFrameWnd, but the class itself is already
big, and moreover it requies instantiating at least 1 CView, which on the
whole is far from light-weight.
Any good suggestions?