I try to write a owner draw listbox with WTL. My code looks like this
template
class ATL_NO_VTABLE CMyListBoxImpl :
public CWindowImpl,
public COwnerDraw
{
...
BEGIN_MSG_MAP(CMyListBoxImpl)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
CHAIN_MSG_MAP(COwnerDraw)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
...
void Init()
{
...
ModifyStyle(0, BS_OWNERDRAW | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS);
...
}
void DrawItem(LPDRAWITEMSTRUCT lpdis)
{
...
I also added REFLECT_NOTIFICATIONS in the parent's message loop, and set Owner Draw to Fixed in property sheet. But I still can't receive the message. Then I used spy++ to examine the message that the listbox receive, I found some message that very strange (WM_USER+7211). Hope someone can help me and point out the mistake I made.
My os is WinXp and use VS2008. Thanks.