tags:

views:

16

answers:

1

I'm trying to get the text from a tab control like this:

TCITEM itm;
        itm.mask = TCIF_TEXT;

        TabCtrl_GetItem(engineGL.controls.MainGlTab.MainTabHwnd,i,&itm);

but the psztext part of the structure is returning a bad pointer (0xcccccccccc).

I create the tabs like this:

void OGLMAINTAB::AddTab( char *name )
{
    TCITEM itm;
    itm.cchTextMax = 30;
    itm.pszText = name;
    itm.mask = TCIF_TEXT;

    int numitems = TabCtrl_GetItemCount(MainTabHwnd);

    SendMessage(MainTabHwnd,TCM_INSERTITEM,numitems,(LPARAM)&itm);
}

why is it not returning the text as I want it to?

Thanks

A: 

When setting the text, cchTextMax is ignored.

When getting the text, you need to provide your own buffer and set cchTextMax accordingly. (Note that when the message returns, you need to use the itm.pszText pointer and not your own buffer since the control will sometimes change the pszText member to point to its internal buffer)

Anders
Didn't know I needed to provide my own buffer, thanks
Milo