Problem with icon style CListCtrl on Vista, but not on XP
-
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
-
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
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
-
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
-
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
-
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
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
-
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
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
-
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
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, likeLVITEM
, so that you aren't accidentally sending garbage data in the members that you don't explicitly set.--Mike-- Dunder-Mifflin, this is Pam
-
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, likeLVITEM
, so that you aren't accidentally sending garbage data in the members that you don't explicitly set.--Mike-- Dunder-Mifflin, this is Pam
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
-
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
There is a method that allows adjustment of the icon width: SetIconSpacing() You might try playing around with that.
-
There is a method that allows adjustment of the icon width: SetIconSpacing() You might try playing around with that.
I haven't had a re-occurrence since I simply initialised my structs, but thanks for pointing that out.