xboxscene.org forums

Author Topic: Xui Settext Driving Me Nuts  (Read 93 times)

node21

  • Archived User
  • Sr. Member
  • *
  • Posts: 385
Xui Settext Driving Me Nuts
« on: February 05, 2010, 07:17:00 AM »

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.



Logged

node21

  • Archived User
  • Sr. Member
  • *
  • Posts: 385
Xui Settext Driving Me Nuts
« Reply #1 on: February 05, 2010, 04:38:00 PM »

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.
Logged