visual c++ - CStatic not receiving WM_CTLCOLOR -
i think missing small here.
i trying make class inherits cstatic transparent background. have managed create instance of class , displayed in parent cview
. when add onctlcolor
message handler going through class view on visual studio make background transparent, never fires.
here code snippet:
foo.h
class foo: public cstatic { declare_dynamic(foo) public: foo(); virtual ~foo(); virtual void createctrl(cwnd * parent, point topleft, size sz); protected: declare_message_map() public: afx_msg hbrush ctlcolor(cdc* pdc, uint nctlcolor); afx_msg bool onerasebkgnd(cdc* pdc); };
foo.cpp
void foo::createctrl(cwnd * parent, point topleft, size sz) { crect rect(topleft, sz); create(pitem->value->getbuffer(), ws_child | ws_visible | ss_center | ss_notify, rect, parent); showwindow(sw_show); } begin_message_map(foo, cstatic) on_wm_ctlcolor_reflect() on_wm_erasebkgnd() end_message_map() hbrush foo::ctlcolor(cdc* pdc, uint nctlcolor) { pdc->setbkmode(transparent); return (hbrush)getstockobject(null_brush); } bool foo::onerasebkgnd(cdc* pdc) { return false; }
can suggest might doing wrong?
wm_ctlcolor
sent parent window, not static control.
to catch message in static control class, need use on_wm_ctlcolor_reflect
in message map, see msdn docs , use hbrush foo::ctlcolor(cdc* pdc, uint nctlcolor)
.
Comments
Post a Comment