That's what I was thinking too. If these are to persist beyond the DrawItem
function they would need to be members of the dialog object at least.
Are you really creating your x and y variables on the stack?
AliR.
"none" <none@none.none> wrote in message
news:Xns9B6B19DB4EF76nonenonenone@69.16.186.8...
Hi,
I derived a control from CStatic. I override PreSubclassWindow() like
so,
to add the SS_OWNERDRAW style:
void CMyStatic::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
ModifyStyle(0, SS_OWNERDRAW);
}
The only other override is the CMyStatic::DrawItem() method, where I do
the
actual drawing. What I find is that if I do this:
RECT some_rect_1, some_rect_2;
CMyStatic x, y;
// (Initialize the rects...)
x.Create("Text", WS_CHILD | WS_VISIBLE | SS_CENTER, some_rect_1, this);
y.Create("Text", WS_CHILD | WS_VISIBLE | SS_RIGHT , some_rect_2, this);
The result is that x is created and draws correctly, but not y.
Debugging,
I find that CMyStatic::DrawItem() is never called for y! However, the
y.Create() function does not return failure, and neither do any other
common window functions, like y.SetWindowText("new text"), etc... but
nothing is ever drawn.
If I remove the SS_OWNERDRAW style, the right-aligned text is drawn, but
the font is strange and the behavior is not what I want.
Thanks in advance for any suggestions.