Solved

Urgent CTabCtrl & CImageList Problem

Posted on 1998-06-12
5
378 Views
Last Modified: 2013-11-20
i am tring to change the tab cntrol to work with CImageList
and it is not working . This is my OnInitDialog() .
What is the problem with it ?? ( IDB_BACK,IDB_FORE are two
bitmaps )


BOOL CMfcDlg::OnInitDialog()
{
      CDialog::OnInitDialog();

      SetIcon(m_hIcon, TRUE);
      SetIcon(m_hIcon, FALSE);
      if (!m_ImageList.Create( 37,20,FALSE,0,2) == true )
            AfxMessageBox("Not O.K");
      if (!m_Fore.LoadBitmap(IDB_FORE))
            AfxMessageBox("Not O.K");
      if (!m_Back.LoadBitmap(IDB_BACK))
            AfxMessageBox("Not O.K");
      int l;
      if ( l = m_ImageList.Add(&m_Fore,WHITE) == -1 )
                  AfxMessageBox("Not O.K");      
      if ( l = m_ImageList.Add(&m_Back,NAVIG_BTN_CLR) == -1 )
                  AfxMessageBox("Not O.K");
      l = m_ImageList.GetImageCount();
      m_TabCtrl.SetImageList(&m_ImageList);
      IMAGEINFO pImageInfo;
      if (m_ImageList.GetImageInfo( 0,&pImageInfo ) == 0)
                  AfxMessageBox("Not O.K");
      

      TC_ITEM local;
      local.mask = TCIF_IMAGE;        
      local.iImage = 0;        
      if (m_TabCtrl.InsertItem(1,&local) == -1 )
            AfxMessageBox("Not O.K");
      TC_ITEM local2;
      local2.mask = TCIF_IMAGE;        
      local2.iImage = 1;        
      if ( m_TabCtrl.InsertItem(2,&local2) == -1 )
                  AfxMessageBox("Not O.K");
      TC_ITEM local3;
      local3.mask = TCIF_IMAGE  ;        
      local3.iImage = 1;        
      if ( m_TabCtrl.InsertItem(3,&local3) == -1 )
            AfxMessageBox("Not O.K");
      m_TabCtrl.SetCurSel(0);
      return TRUE;
}
0
Comment
Question by:moshei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:shaig
ID: 1317903
This simple code works:

CTabCtrl *pTab = GetTabControl();  // not relevant for you
if( pTab == NULL ) return bResult;
m_pImageList = new CImageList;
if( m_pImageList == NULL ) return bResult;
if( !m_pImageList->Create( 16, 16, TRUE, 2, 2 ) ) return bResult;
INT nImageIndex = m_pImageList->Add( pApp->LoadIcon(     IDI_CASSETTE )
    );
if( nImageIndex == -1 ) return bResult;
pTab->SetImageList( m_pImageList );
TC_ITEM tabCtrlItem;
tabCtrlItem.mask = TCIF_IMAGE;
tabCtrlItem.iImage = nImageIndex;
pTab->SetItem( 0, &tabCtrlItem );
0
 

Author Comment

by:moshei
ID: 1317904
This code is not working within my program and the tab is opened
with the default look.
0
 

Author Comment

by:moshei
ID: 1317905
My CTabCtrl is an owner draw control
0
 

Author Comment

by:moshei
ID: 1317906
Adjusted points to 70
0
 
LVL 3

Accepted Solution

by:
shaig earned 70 total points
ID: 1317907
This code is taken out of a working program.
is your tab control created? ( does he have a valide HWND )
can you supply more details if not, so i can be moer helpful
( like, is there a spot in this code i've supplied that fails - does the code execute till it's last line or does it break on it's way? )
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 51
Tab names are off by one 5 54
mapAB Challlenge 35 180
Notepad++ Question 11 24
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question