tags:

views:

106

answers:

1

I want to set the background image of a ListView control in my Shell Extension. The ListView inherits IShellView and I am using the following code:-

HBITMAP m_hBmp = (HBITMAP)::LoadImage( hinst, 
    MAKEINTRESOURCE( IDB_BITMAP1 ), IMAGE_BITMAP, 0, 0, 
    LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);
if ( m_hBmp )
{
    LVBKIMAGE bki;
    bki.ulFlags= LVBKIF_SOURCE_HBITMAP;
    bki.hbm = m_hBmp;
    bki.cchImageMax = sizeof( bki.hbm );
    bki.xOffsetPercent = 50;
    bki.yOffsetPercent = 50;
    ListView_SetBkImage(m_hwndList,&bki);
}

The above code works fine in Vista but for some reason it does not work in XP. Is there anything that I am missing?

+1  A: 

To make it work in both versions(XP and Vista), we used both the approaches. For XP, we are loading the image from file and for Vista we are loading it from resource. For some reason, loading from file does not work in Vista and loading from resource handle does not work in XP.

So the approach is to load it from file first and then if it fails, load from resource handle.

A9S6

related questions