#include "SRTabCtrl.h" #include "SRApp.h" #include using namespace SRFramework; SRTabCtrl::SRTabCtrl(void) { INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&InitCtrlEx); m_hInstance = SRFramework::SRApp::GetInstanceHandle(); m_wcsClassName = WC_TABCONTROL; m_wcsWindowName = ""; } SRTabCtrl::~SRTabCtrl(void) { } BOOL SRTabCtrl::Create(SRWnd *pParentWnd, RECT bounds, DWORD dwStyle) { if(!Register()) return FALSE; if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName, dwStyle, bounds, pParentWnd, NULL, m_hInstance)) return FALSE; return TRUE; } BOOL SRTabCtrl::DeleteAllItems(VOID) { return TabCtrl_DeleteAllItems(m_hWnd); } BOOL SRTabCtrl::DeleteItem(int nItem) { return TabCtrl_DeleteItem(m_hWnd, nItem); } BOOL SRTabCtrl::DeselectAll(BOOL fExcludeFocus) { TabCtrl_DeselectAll(m_hWnd, fExcludeFocus); return TRUE; } BOOL SRTabCtrl::HighlightItem(int idItem, BOOL fHighlight) { return TabCtrl_HighlightItem(m_hWnd, idItem, fHighlight); } INT SRTabCtrl::HitTest(LPTCHITTESTINFO pHitTestInfo) const { return TabCtrl_HitTest(m_hWnd, pHitTestInfo); } LONG SRTabCtrl::InsertItem(int nItem, TC_ITEM* pTabCtrlItem) { return TabCtrl_InsertItem(m_hWnd, nItem, pTabCtrlItem); } LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem) { return InsertItem(nItem, wcsItem, -1, NULL); } LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem, int nImage) { return InsertItem(nItem, wcsItem, nImage, NULL); } LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem, int nImage, LPARAM lParam) { BOOL retval = 0; TC_ITEM item; LPWSTR pszText = (LPWSTR)calloc(wcsItem.length() + 1, sizeof(WCHAR)); if(!pszText) return -1; wcscpy(pszText, wcsItem.w_str()); memset(&item, 0, sizeof(TC_ITEM)); item.mask = TCIF_TEXT; if(nImage > -1) item.mask |= TCIF_IMAGE; if(lParam != NULL) item.mask |= TCIF_PARAM; item.pszText = pszText; item.cchTextMax = wcsItem.length() + 1; item.iImage = nImage; item.lParam = lParam; retval = TabCtrl_InsertItem(m_hWnd, nItem, &item); delete pszText; return retval; } VOID SRTabCtrl::RemoveImage(int nImage) { return TabCtrl_RemoveImage(m_hWnd, nImage); } INT SRTabCtrl::GetCurFocus() { return TabCtrl_GetCurFocus(m_hWnd); } INT SRTabCtrl::GetCurSel() { return TabCtrl_GetCurSel(m_hWnd); } INT SRTabCtrl::GetItemCount() { return TabCtrl_GetItemCount(m_hWnd); } BOOL SRTabCtrl::GetItemRect(INT nItem, LPRECT lpRect) { return TabCtrl_GetItemRect(m_hWnd, nItem, lpRect); } INT SRTabCtrl::GetRowCount() { return TabCtrl_GetRowCount(m_hWnd); } BOOL SRTabCtrl::SetCurFocus(INT nItem) { return TabCtrl_SetCurFocus(m_hWnd, nItem); } BOOL SRTabCtrl::SetCurSel(INT nItem) { return TabCtrl_SetCurSel(m_hWnd, nItem); } INT SRTabCtrl::SetMinTabWidth(INT cx) { return TabCtrl_SetMinTabWidth(m_hWnd, cx); } BOOL SRTabCtrl::SetPadding(INT cx, INT cy) { TabCtrl_SetPadding(m_hWnd, cx, cy); return TRUE; }