Reputation: 1332
I am trying to do owner-draw tab control. In DRAWITEMSTRUCT structure, I get some information about a tab item that is being drawn, like its rectangle, hDC, hwnd, but I can't not find its text which is given when it is created (LPTSTR pszText member of the LPTSTR TCITEM structure).
How to get the text of a tab item when one wants to do owner-draw?
Upvotes: 0
Views: 375
Reputation: 941307
The universal way is documented in the SDK article for tab controls:
By default, the itemData member of DRAWITEMSTRUCT contains the value of the lParam member of the TCITEM structure. However, if you change the amount of application-defined data per tab, itemData contains the address of the data instead. You can change the amount of application-defined data per tab by using the TCM_SETITEMEXTRA message.
So you can always hang a pointer on the TCITEMs you add and get it back through itemData. Which is enough to get any info back about the tab, including data that you maintain yourself.
Not actually necessary if you only need the text. You can simply use TCM_GETITEM to get a TCITEM back. Pass DRAWITEMSTRUCT.itemID.
Upvotes: 2