I'm having a really hard time understanding why my CXuiTextElements don't always respond to SetText(). It's reproducible, but not consistent. I initially thought it had to do with doing long operations immediately after doing the SetText not allowing a PAINT to get through...but I'm completely discounting that idea now.
Anyway, the control is defined as such in the class:
CODE
CXuiTextElement m_TitleForHeading;
And the OnInit() function does this:
CODE
HRESULT hr = GetChildById( L"XuiTextTitleForHeading", &m_TitleForHeading);
DebugMsg("HRESULT IS %x", hr);
Of course, the HRESULT is always S_OK;
Later I do this:
CODE
hr = m_TitleForHeading.SetText(L"DLC Is For (All)");
DebugMsg("HR is %x", hr);
And that *always* seems to work.
Based on some keydown events, I then do:
CODE
hr = m_TitleForHeading.SetText(L"DLC Is For (Have)");
DebugMsg("HR2 is %x", hr);
which seems to *never* work, but hr is always S_OK;
Oddly enough, if I replace that code with this:
CODE
hr = XuiTextElementSetText(m_TitleForHeading, L"DLC Is For (Have)");
DebugMsg("HR5 is %x", hr);
It seems to work sometimes, but not always.
Anyway, please tell me that I'm doing something really stupid, and this should always work...Well, I know it always *should* work...can anyone lend a hand and explain this behavior please?
Thanks.
Okay, I've figured this out. And it's completely embarrassing. Instead of just spilling the beans and exposing my stupidity, I've decided to leave this here as a game. As it turns out, there is enough information in what I posted above that someone might be able to correctly guess my fairly common oversight.
Any takers? (IMG:style_emoticons/default/jester.gif)
One hint though: Forget what I said about CODE
hr = XuiTextElementSetText(m_TitleForHeading, L"DLC Is For (Have)");
DebugMsg("HR5 is %x", hr);
Sometimes working...since, now that I understand the problem, that could not have been the case exactly as written.