Redraw a CStatic,create it using Create,but the function DrawItem doesn't been run
-
the following are the related code,could someone can help me,
void CXXXStatic::PreSubclassWindow()
{
// TODO: 在此添加专用代码和/或调用基类
DWORD dwStyle = GetStyle();
SetWindowLong(GetSafeHwnd(),GWL_STYLE,dwStyle | SS_OWNERDRAW);
CStatic::PreSubclassWindow();}
void CXXXStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: 添加您的代码以绘制指定项
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);}
CXXXStatic m_Static;
m_Static.Create("hello", WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(100, 100, 200, 200), this,0x0301); -
the following are the related code,could someone can help me,
void CXXXStatic::PreSubclassWindow()
{
// TODO: 在此添加专用代码和/或调用基类
DWORD dwStyle = GetStyle();
SetWindowLong(GetSafeHwnd(),GWL_STYLE,dwStyle | SS_OWNERDRAW);
CStatic::PreSubclassWindow();}
void CXXXStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: 添加您的代码以绘制指定项
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);}
CXXXStatic m_Static;
m_Static.Create("hello", WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(100, 100, 200, 200), this,0x0301);That is because
SS_OWNERDRAW
is not a bit value that can be O-red to the style but a masked value. UseSetWindowLong(GetSafeHwnd(),GWL_STYLE,( dwStyle & ~SS_TYPEMASK) | SS_OWNERDRAW);
instead. Or better:
ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW));