*ahem* Did someone say
tabs?
WinGUI with TAB support now.
The new commands (source code):
// Create a tab control
DLLCMDC HWND gui_makeTabControl(int x, int y, int width, int height, HWND hParent)
{
InitCommonControls();
return CreateWindow(WC_TABCONTROL, "", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, x, y, width, height, hParent, 0, GetModuleHandle(0), 0);
}
// Add a tab to a tab control
DLLCMDC int gui_addTab(HWND hTabControl, int index, char* szText)
{
if (index == -1)
index = 0xffffff;
TCITEM tab;
tab.mask = TCIF_TEXT | TCIF_IMAGE;
tab.iImage = -1;
tab.pszText = szText;
return TabCtrl_InsertItem(hTabControl, index, &tab);
}
// Set the current tab in a tab control
DLLCMDC void gui_setTab(HWND hTabControl, int iIndex)
{
TabCtrl_SetCurSel(hTabControl, iIndex);
}
// Retrieve the current tab in a tab control
DLLCMDC int gui_getTab(HWND hTabControl)
{
return TabCtrl_GetCurSel(hTabControl);
}
// Retrieve how many tabs are in a tab control
DLLCMDC int gui_getTabCount(HWND hTabControl)
{
return TabCtrl_GetItemCount(hTabControl);
}
// Destroy a tab in a tab control
DLLCMDC void gui_destroyTab(HWND hTabControl, int iIndex)
{
TabCtrl_DeleteItem(hTabControl, iIndex);
}
// Destroy all the tabs in a tab control
DLLCMDC void gui_destroyAllTabs(HWND hTabControl)
{
TabCtrl_DeleteAllItems(hTabControl);
}
// Set the text of a tab
DLLCMDC void gui_setTabText(HWND hTabControl, int iIndex, char* szText)
{
TCITEM item;
char szBuff[256];
memset(szBuff, 0, 256);
item.mask = TCIF_TEXT;
item.cchTextMax = 255;
item.pszText = szBuff;
if (TabCtrl_GetItem(hTabControl, iIndex, &item) == TRUE)
{
strcpy(szBuff, szText);
item.pszText = szBuff;
TabCtrl_SetItem(hTabControl, iIndex, &item);
}
}
It didn't take me this long to write this code, it took me this long to make MSVC++ play nice (As I had to uninstall vista temporarily, now I have reinstalled it
).
Download:
WinGUI 10/15/07
Cheers,
-naota