Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with icon style CListCtrl on Vista, but not on XP

Problem with icon style CListCtrl on Vista, but not on XP

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicssaleshelpquestion
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sternocera
    wrote on last edited by
    #1

    Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

    CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
    {
    // Load your imagelist bitmap (bmp) here, however
    // you feel like (e.g. CBitmap::LoadBitmap)
    CBitmap sales_bitmap,
    daily_reconciliation_bitmap,
    debtor_statement_bitmap,
    debtor_invoice_bitmap,
    voided_items_bitmap,
    suspended_sales_bitmap,
    stock_count_rep_bitmap,
    live_stock_figures_bitmap,
    sales_by_item,
    pos_download_bitmap;

    sales\_bitmap.LoadBitmap(IDB\_SALES);
    daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
    debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
    debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
    voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
    suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
    stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
    live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
    sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
    pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
    
    // Set up your transparent colour as appropriate
    COLORREF rgbTransparentColour = RGB(255, 255, 255);
    imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
    
    // Add the bitmap into the image list
    int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
    int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
    int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
    int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
    int voided\_itms\_bit\_id = imgl.Add
    
    S D M G 4 Replies Last reply
    0
    • S Sternocera

      Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

      CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
      {
      // Load your imagelist bitmap (bmp) here, however
      // you feel like (e.g. CBitmap::LoadBitmap)
      CBitmap sales_bitmap,
      daily_reconciliation_bitmap,
      debtor_statement_bitmap,
      debtor_invoice_bitmap,
      voided_items_bitmap,
      suspended_sales_bitmap,
      stock_count_rep_bitmap,
      live_stock_figures_bitmap,
      sales_by_item,
      pos_download_bitmap;

      sales\_bitmap.LoadBitmap(IDB\_SALES);
      daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
      debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
      debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
      voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
      suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
      stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
      live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
      sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
      pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
      
      // Set up your transparent colour as appropriate
      COLORREF rgbTransparentColour = RGB(255, 255, 255);
      imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
      
      // Add the bitmap into the image list
      int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
      int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
      int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
      int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
      int voided\_itms\_bit\_id = imgl.Add
      
      S Offline
      S Offline
      Sternocera
      wrote on last edited by
      #2

      I seem to have isolated the problem somewhat (It still erratically tends to swing between omitting and not omitting the icon between builds, I guess). By commenting out: ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); I can make the problem disappear (although I have a new problem, which is that the icons are displayed as one big column). Commenting out anything else of note doesn't have the effect of suppressing the problem, so I guess that's progress. Regards, Sternocera

      L 1 Reply Last reply
      0
      • S Sternocera

        I seem to have isolated the problem somewhat (It still erratically tends to swing between omitting and not omitting the icon between builds, I guess). By commenting out: ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); I can make the problem disappear (although I have a new problem, which is that the icons are displayed as one big column). Commenting out anything else of note doesn't have the effect of suppressing the problem, so I guess that's progress. Regards, Sternocera

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi Sternocera, Where are you setting the column width?

        S 1 Reply Last reply
        0
        • L Lost User

          Hi Sternocera, Where are you setting the column width?

          S Offline
          S Offline
          Sternocera
          wrote on last edited by
          #4

          Hi Randor, I'm not - it isn't a report style CListCtrl, it's an icon style CListCtrl. I understand that column width isn't set with an icon style CListCtrl. Regards, Sternocera

          1 Reply Last reply
          0
          • S Sternocera

            Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

            CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
            {
            // Load your imagelist bitmap (bmp) here, however
            // you feel like (e.g. CBitmap::LoadBitmap)
            CBitmap sales_bitmap,
            daily_reconciliation_bitmap,
            debtor_statement_bitmap,
            debtor_invoice_bitmap,
            voided_items_bitmap,
            suspended_sales_bitmap,
            stock_count_rep_bitmap,
            live_stock_figures_bitmap,
            sales_by_item,
            pos_download_bitmap;

            sales\_bitmap.LoadBitmap(IDB\_SALES);
            daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
            debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
            debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
            voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
            suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
            stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
            live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
            sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
            pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
            
            // Set up your transparent colour as appropriate
            COLORREF rgbTransparentColour = RGB(255, 255, 255);
            imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
            
            // Add the bitmap into the image list
            int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
            int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
            int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
            int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
            int voided\_itms\_bit\_id = imgl.Add
            
            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Have you entertained the possibility of a bad/corrupt/outdated icon cache? I've had it happen once with an older version of Windows, so it's probably not a common problem.

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            S 1 Reply Last reply
            0
            • D David Crow

              Have you entertained the possibility of a bad/corrupt/outdated icon cache? I've had it happen once with an older version of Windows, so it's probably not a common problem.

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              S Offline
              S Offline
              Sternocera
              wrote on last edited by
              #6

              That seems like a reasonable explanation. I've found that moving the initialisation of the icons into OnIntialUpdate seems to fix the problem, but I'm not overly confident that it hasn't just temporarily concealed the problem. I'll delete the cache to be sure. Regards, Sternocera

              1 Reply Last reply
              0
              • S Sternocera

                Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

                CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
                {
                // Load your imagelist bitmap (bmp) here, however
                // you feel like (e.g. CBitmap::LoadBitmap)
                CBitmap sales_bitmap,
                daily_reconciliation_bitmap,
                debtor_statement_bitmap,
                debtor_invoice_bitmap,
                voided_items_bitmap,
                suspended_sales_bitmap,
                stock_count_rep_bitmap,
                live_stock_figures_bitmap,
                sales_by_item,
                pos_download_bitmap;

                sales\_bitmap.LoadBitmap(IDB\_SALES);
                daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
                debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
                debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
                voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
                suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
                stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
                live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
                sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
                pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
                
                // Set up your transparent colour as appropriate
                COLORREF rgbTransparentColour = RGB(255, 255, 255);
                imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
                
                // Add the bitmap into the image list
                int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
                int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
                int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
                int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
                int voided\_itms\_bit\_id = imgl.Add
                
                M Offline
                M Offline
                Michael Dunn
                wrote on last edited by
                #7

                Where is imgl declared? Is its lifetime longer than the lifetime of the list control? It's a good idea to always zero-init structs, like LVITEM, so that you aren't accidentally sending garbage data in the members that you don't explicitly set.

                --Mike-- Dunder-Mifflin, this is Pam

                S 1 Reply Last reply
                0
                • M Michael Dunn

                  Where is imgl declared? Is its lifetime longer than the lifetime of the list control? It's a good idea to always zero-init structs, like LVITEM, so that you aren't accidentally sending garbage data in the members that you don't explicitly set.

                  --Mike-- Dunder-Mifflin, this is Pam

                  S Offline
                  S Offline
                  Sternocera
                  wrote on last edited by
                  #8

                  Hi Mike, Yes, imgl is declared in the same class definition as the CListCtrl. I have now zero initialised the LVITEM structs. Thanks for your help. Regards, Sternocera

                  1 Reply Last reply
                  0
                  • S Sternocera

                    Hello, I'm working on an MFC application. For reasons I cannot fathom, there seems to be a problem with inconsistent display of the icons of an icon style CListCtrl between versions of Windows (XP and Vista). On Vista, one of the icons (Debtor statement) is omitted. This only occurs sometimes. When it actually occurs varies from build to build of the application, where changes between builds ought to have no bearing on this at all. Why might this be? How can the problem be fixed? Here is the relevant code: CMyReportView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); ReportsCtrl.ModifyStyle(0, LVS_AUTOARRANGE); // Send an ID_RELOAD rather than calling UpdateStateData() directly - this is // a hack to work around the problem of no icons being displayed initially // in release build SendMessage(ID_RELOAD ); }

                    CMyReportView::UpdateData() // called when ID_RELOAD is received, sent from OnInitialUpdate
                    {
                    // Load your imagelist bitmap (bmp) here, however
                    // you feel like (e.g. CBitmap::LoadBitmap)
                    CBitmap sales_bitmap,
                    daily_reconciliation_bitmap,
                    debtor_statement_bitmap,
                    debtor_invoice_bitmap,
                    voided_items_bitmap,
                    suspended_sales_bitmap,
                    stock_count_rep_bitmap,
                    live_stock_figures_bitmap,
                    sales_by_item,
                    pos_download_bitmap;

                    sales\_bitmap.LoadBitmap(IDB\_SALES);
                    daily\_reconciliation\_bitmap.LoadBitmap(IDB\_DAILY\_RECONCILIATION);
                    debtor\_statement\_bitmap.LoadBitmap(IDB\_DEBTOR\_STATEMENT); 
                    debtor\_invoice\_bitmap.LoadBitmap(IDB\_DEBTOR\_INVOICE); 
                    voided\_items\_bitmap.LoadBitmap(IDB\_ICON\_VOID); 
                    suspended\_sales\_bitmap.LoadBitmap(IDB\_SUSPENDED\_SALES\_ICON);
                    stock\_count\_rep\_bitmap.LoadBitmap(IDB\_STOCK\_COUNT\_REPORT\_ICON);
                    live\_stock\_figures\_bitmap.LoadBitmap(IDB\_ICON\_LIVE\_STOCK\_FIGURES);
                    sales\_by\_item.LoadBitmap(IDB\_SALES\_BY\_ITEM\_ICON);
                    pos\_download\_bitmap.LoadBitmap(IDB\_POS\_DOWNLOAD\_REPORT\_ICON);
                    
                    // Set up your transparent colour as appropriate
                    COLORREF rgbTransparentColour = RGB(255, 255, 255);
                    imgl.Create(64, 64, ILC\_MASK | ILC\_COLOR32, 0, 0);
                    
                    // Add the bitmap into the image list
                    int sales\_bit\_id = imgl.Add(&sales\_bitmap, rgbTransparentColour);
                    int daily\_rec\_bit\_id = imgl.Add(&daily\_reconciliation\_bitmap, rgbTransparentColour);
                    int debtor\_stat\_bit\_id = imgl.Add(&debtor\_statement\_bitmap, rgbTransparentColour);
                    int debt\_invo\_bit\_id = imgl.Add(&debtor\_invoice\_bitmap, rgbTransparentColour);
                    int voided\_itms\_bit\_id = imgl.Add
                    
                    G Offline
                    G Offline
                    Greg Prosch 1
                    wrote on last edited by
                    #9

                    There is a method that allows adjustment of the icon width: SetIconSpacing() You might try playing around with that.

                    S 1 Reply Last reply
                    0
                    • G Greg Prosch 1

                      There is a method that allows adjustment of the icon width: SetIconSpacing() You might try playing around with that.

                      S Offline
                      S Offline
                      Sternocera
                      wrote on last edited by
                      #10

                      I haven't had a re-occurrence since I simply initialised my structs, but thanks for pointing that out.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups