How to change the bitmaps of an Outlookbar style property sheet (class CMFCPropertySheet )

Ramesh Deekonda 216 Reputation points
2021-10-20T08:07:21.237+00:00

Hi,
I have created a property sheet derived from CMFCPropertySheet with three pages. I am using the property sheet in Outlookbar style.
I use the SetLook member function to set the CMFCPropertySheet::PropSheetLook_Outlookbar style. I am able to assign the Bitmaps once befor the call to DoModal().I would like to change the bitmaps on the buttons of this propertysheet after it has been created.
Once bitmaps have been et I am not able to change the bitmaps later. I would like one bitmap displayed in the selected state and another when it is unselected. Please give your suggestions on how I can do this.
I have created a function to change the image list that is used by the property sheet which is as below. This function is called from the OnSetActive function of the property pages of the property sheet.

void AppPropSheet::ChangeImgList(int sel)
{
//m_bmpimgs[3] and m_bmpmask are member variables of the AppPropSheet class

    static bool firsttime = true;

    int retval;

    if (!firsttime)
        for (int i = 0; i < 3; i++)
        {
        m_bmpimgs[i].~CBitmap();
        }


    if (sel == 0)
        m_bmpimgs[0].LoadBitmapA(IDB_BITMAP87);
    else
        m_bmpimgs[0].LoadBitmapA(IDB_BITMAP77);

    if (sel == 1)
        m_bmpimgs[1].LoadBitmapA(IDB_BITMAP86);
    else
        m_bmpimgs[1].LoadBitmapA(IDB_BITMAP81);

    if (sel == 2)
        m_bmpimgs[2].LoadBitmapA(IDB_BITMAP88);
    else
        m_bmpimgs[2].LoadBitmapA(IDB_BITMAP79);

    if(firsttime)
    m_bmpmask.LoadBitmapA(IDB_BITMAP80);


    if (!firsttime)
    {
        m_shtSelImages.Remove(2);
        m_shtSelImages.Remove(1);
        m_shtSelImages.Remove(0);
        ImageList_Destroy(m_shtSelImages.m_hImageList);
        retval = m_shtSelImages.Create(81, 81, ILC_COLOR24 | ILC_MASK, 1, 1);

        retval=m_shtSelImages.Add(&bmpimgs[0],RGB(128,128,128));
        retval=m_shtSelImages.Add(&bmpimgs[1], RGB(128, 128, 128));
        retval=m_shtSelImages.Add(&bmpimgs[2], RGB(255, 255, 255));

        //SetIconsList(m_shtSelImages.m_hImageList);//commented because it asserts here
        RedrawWindow();
    }
    firsttime = false;

}
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,426 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,537 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ramesh Deekonda 216 Reputation points
    2021-10-24T15:32:00.757+00:00

    @Castorix31 , I am obliged for his work on my question.The bitmaps that are used should all be of same size I think otherwise the output is getting mixed up. This is the working code for achieving the changed buttons.However the change of images is no so smooth.

    void  ChangeImageList(int sel)  
    {  
             for (int i = 0; i < 3; i++)  
                  {  
                  m_bmpimgs[i].~CBitmap();  
                  }  
              if (sel == 0)  
                    retval=m_bmpimgs[0].LoadBitmapA(IDB_BITMAP87);  
              else  
                    retval=m_bmpimgs[0].LoadBitmapA(IDB_BITMAP77);  
                      
              if (sel == 1)  
                    retval=m_bmpimgs[1].LoadBitmapA(IDB_BITMAP86);  
              else  
                    retval=m_bmpimgs[1].LoadBitmapA(IDB_BITMAP81);  
                      
              if (sel == 2)  
                    retval=m_bmpimgs[2].LoadBitmapA(IDB_BITMAP88);  
              else  
                    retval=m_bmpimgs[2].LoadBitmapA(IDB_BITMAP79);  
                            
              m_wndPane1.RemoveAllButtons();  
          
              //This line not to be used  
              //m_wndPane1.ClearAll();  
                      
              retval=m_wndPane1.AddButton(m_bmpimgs[0], "Button one text", 10050, 0);  
              retval=m_wndPane1.AddButton(m_bmpimgs[1], "Button Two Text", 10051, 1);  
              retval=m_wndPane1.AddButton(m_bmpimgs[2], "Button three text", 10052, 2);  
                                   
              m_wndPane1.InvalidateButton(0);  
              m_wndPane1.InvalidateButton(1);  
              m_wndPane1.InvalidateButton(2);  
                      
    }  
    
    
    
    
    
    
      
      
      
      
      
      
      
      
      
      
      
      
    

2 additional answers

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,496 Reputation points Microsoft Vendor
    2021-10-21T06:37:03.953+00:00

    Generally, after getting the handle to the buttons, you can change their bitmap anytime. Searching Hacking the CPropertySheet for more details.


  2. Ramesh Deekonda 216 Reputation points
    2021-10-22T06:01:11.22+00:00

    The framework seems to use its own copy of the bitmaps which are stored internally and not accessible.In which event can I do my own painting in the tab area which will not be over painted later by the framework.