CTabCtrl 控件显示位图或者图标

BOOL CMyPropSheet::OnInitDialog()

{

BOOL bResult = CPropertySheet::OnInitDialog();

 

m_imageTab.Create( IDB_TABIMAGES, 13, 1, RGB(255,255,255) );  //创建一个CImageList的类

CTabCtrl *pTab = GetTabControl();

pTab->SetImageList( &m_imageTab );                             //tab控件设置ImageList

//也可可以不指定像素,可以使用CImageList 的Add方法实现,可以Add位图或者图标

TC_ITEM tcItem;

tcItem.mask = TCIF_IMAGE;

for( int i = 0; i < 3; i++ )

{

tcItem.iImage = i;

pTab->SetItem( i, &tcItem );                            //显示ImageList的序号

}

return bResult;

}

我做一个显示ICO的例子

CTabCtrl  m_TabPanel;

CImageList  m_ImageList;

m_ImageList.Create(16,16,ILC_COLOR8|ILC_MASK,3,0);

m_ImageList.Add(::AfxGetApp()->LoadIconA(IDI_ICON1));

m_ImageList.Add(::AfxGetApp()->LoadIconA(IDI_ICON2));

m_ImageList.Add(::AfxGetApp()->LoadIconA(IDI_ICON3));

m_TabPanel.SetImageList(&m_ImageList);

m_TabPanel.InsertItem(0,_T(“配置参数”),0);

m_TabPanel.InsertItem(1,_T(“号码添加”),1);

m_DlgPage1.Create(IDD_DLG_ONE,GetDlgItem(IDC_TAB_PANEL));        //关联对话框

m_DlgPage2.Create(IDD_DLG_TWO,GetDlgItem(IDC_TAB_PANEL));

转载于:https://www.cnblogs.com/rogee/archive/2011/05/24/2055904.html

你可能感兴趣的:(CTabCtrl 控件显示位图或者图标)