I am using Win32 for my GUI.
I have TabControl and TabItem classes. The TabItem class simply holds a TCITEM struct and the TabControl->AddTab method takes a TabItem as an argument and accesses that struct.
class TabItem {
public:
TabItem(LPWSTR lpszText);
~TabItem();
public:
TCITEM* GetItem();
private: (... there is more data here, related to the actual page contents)
TCITEM* m_pItem;
};
class TabControl {
public:
TabControl(HWND hWnd, INT iX, INT iY, DWORD dwWidth, DWORD dwHeight);
~TabControl();
public:
VOID AddTab(TabItem* tiTab);
VOID RemoveTab(INT nIndex);
VOID ClearTabs();
VOID SetSelectedItem(INT nIndex);
INT GetSelectedItem();
INT GetFocusedItem();
VOID SetPadding(INT iPaddingX, INT iPaddingY);
private:
HWND m_hWnd;
};
To add a tab page:
TCITEM* TabItem::GetItem()
{
return this->m_pItem;
}
...
TabCtrl_InsertItem(this->m_hWnd, TabCtrl_GetItemCount(this->m_hWnd), tiTab->GetItem());
After the tabs have been added they can be re-arranged, moved left/right etc. The problem I have is that I need to get a handle of a TabItem class based on a tab index (ie: one returned by TabCtrl_GetSelected), as the TabItem class holds additional info on the actual contents of the tab page. I'm unsure how to do this.