Seems like the current available Win32 API documentation is inaccurate and / or incomplete regarding how to pass extra data properly using TCM_SETITEMEXTRA message and TCITEMHEADER structure.
And finally, the data size requirement when one wants to pass extra data using TCITEMHEADER is inaccurately documented as well. <https://learn.microsoft.com/en-us/windows/win32/controls/tcm-setitemextra#remarks> says "By default, the number of extra bytes is four." which is valid for 32-bit apps/calls only. In 64-bit apps this default size appears to be 8 bytes since if you set this size by sending a TCM_SETITEMEXTRA message then it is silently discarded and things fall back to the old way when TCITEM is used: you get a 4-byte-long truncated value again when getting tab info and the same wrong _value_ passed through messages containing DRAWITEMSTRUCTs (and not reference to the extra data, as described in <https://learn.microsoft.com/en-us/windows/win32/controls/tab-controls?redirectedfrom=MSDN#owner-drawn-tabs>).
As a workaround, to avoid the extra data size to be either 4 or 8, a dummy byte is added to the extra data structure which makes things work in both architectures.
Seems like the current available Win32 API documentation is inaccurate and / or incomplete regarding how to pass extra data properly using TCM_SETITEMEXTRA message and TCITEMHEADER structure.
First of all (as people also noted in a few other online forums), for TCITEMHEADER the TCIF_PARAM flag in "mask" parameter must be set the same way as in <https:/ /learn. microsoft. com/en- us/windows/ win32/api/ commctrl/ ns-commctrl- tcitema# members> when used for getting or setting a tab item's data. <https:/ /learn. microsoft. com/en- us/windows/ win32/api/ commctrl/ ns-commctrl- tcitemheadera# members> omits this information.
Secondly, unlike the way documented in <https:/ /learn. microsoft. com/en- us/windows/ win32/api/ commctrl/ nf-commctrl- tabctrl_ setitemextra> the TabCtrl_ SetItemExtra macro indeed has a success/failure return value, it is clear from CommCtrl.h.
And finally, the data size requirement when one wants to pass extra data using TCITEMHEADER is inaccurately documented as well. <https:/ /learn. microsoft. com/en- us/windows/ win32/controls/ tcm-setitemextr a#remarks> says "By default, the number of extra bytes is four." which is valid for 32-bit apps/calls only. In 64-bit apps this default size appears to be 8 bytes since if you set this size by sending a TCM_SETITEMEXTRA message then it is silently discarded and things fall back to the old way when TCITEM is used: you get a 4-byte-long truncated value again when getting tab info and the same wrong _value_ passed through messages containing DRAWITEMSTRUCTs (and not reference to the extra data, as described in <https:/ /learn. microsoft. com/en- us/windows/ win32/controls/ tab-controls? redirectedfrom= MSDN#owner- drawn-tabs>).
As a workaround, to avoid the extra data size to be either 4 or 8, a dummy byte is added to the extra data structure which makes things work in both architectures.