0

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.

kvanbere
  • 3,289
  • 3
  • 27
  • 52
  • 2
    Use the TCITEM.lParam to store the pointer to TabItem – Vishal Jul 22 '12 at 10:51
  • Excellent! I also did some more research and found I could use a TCITEMHEADER and my own struct as a parameter to GET/SETitem, so I'm going to run with the second option. If you post that as an answer though, I'll select it. – kvanbere Jul 22 '12 at 11:22
  • I'll be happy with an upvote on my comment :-) – Vishal Jul 22 '12 at 11:53

0 Answers0