umeca74 | 5 Jun 2002 15:28
Picon
Favicon

Re: MFC like subclassing via class inheritance

--- In wtl@..., "offcity97" <offcity <at> n...> wrote:
> Hi, in MFC if I want to override WM_CHAR message,
> I would do like class CMyEdit : public CEdit.
> However, in WTL how can I do such thing?

you can do this but it won't help you trapping any messages.
Instead you need to create your own edit subclass like:

class CMyEdit : public CWindowImpl<CMyEdit, CEdit>
{
DECLARE_WND_SUPERCLASS(_T("MyEdit"), CEdit::GetWndClassName())

BEGIN_MSG_MAP(CMyEdit)
MESSAGE_HANDLER(WM_CHAR, OnChar)
END_MSG_MAP()

LRESULT OnChar(UINT uMsg, WPARAM wp, LPARAM lp, BOOL& bHandled)
{
...
}

};

It's a bit more work than MFC since you'll have to do your own 
message cracking (but take a look at WTL's atlcrack.h for assistance 
on this subject). Other than that, the SDK docs on WM_CHAR and all 
the other messages come to your rescue :)

HTH
Nikos


Gmane