Why did the ImageList controls show black icon in XP?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I used the ImageList controls to show some images.
the control showed correctly in win7. However, the one showed some black icons in XP.
I didnt know why was incorrectly in XP.
i sure the images was correctly.
this was initialize codes:HWND hQQWnd = FindWindowW( nullptr, L"QQ2013" );
if( nullptr == hQQWnd )
{
MessageBoxW( nullptr, L"-1", L"可乐木木", MB_OK );
break;
}

HDC hSrcDC = CreateDCW( L"DISPLAY", nullptr, nullptr, nullptr );
if( nullptr == hSrcDC )
{
MessageBoxW( nullptr, L"aaa", L"可乐木木", MB_OK );
break;
}

HDC hMemDC = CreateCompatibleDC( hSrcDC );
if( nullptr == hMemDC )
{
MessageBoxW( nullptr, L"bbb", L"可乐木木", MB_OK );
break;
}

bool bVisible = true;

if( !IsWindowVisible( hQQWnd ) )
{
bVisible = false;
ShowWindow( hQQWnd, SW_NORMAL );
}

RECT rctQQWnd = { };
GetWindowRect( hQQWnd, &rctQQWnd );

SetWindowPos( hQQWnd, HWND_TOPMOST, 400, 0, NULL, NULL, SWP_NOSIZE );

HandleBitmap hBmp = CreateCompatibleBitmap( hSrcDC, 200, 60 );
SelectObject( hMemDC, hBmp );
BitBlt( hMemDC, 0, 0, 200, 60, hSrcDC, 400, 0, SRCCOPY );

ListView_SetExtendedListViewStyle( GetDlgItem( hWnd, IDC_LIST1 ), LVS_EX_CHECKBOXES );

HIMAGELIST hImageList = ImageList_Create( 200, 60, ILC_COLOR24, 1, 2 );
ListView_SetImageList( GetDlgItem( hWnd, IDC_LIST1 ), hImageList, LVSIL_SMALL );

LVITEM lvi = { };
lvi.mask = LVIF_IMAGE;
lvi.iItem = INT_MAX;
lvi.iImage = ImageList_Add( hImageList, hBmp, nullptr );
if( -1 == lvi.iImage )
MessageBoxW( nullptr, L"可乐木木", L"可乐木木", MB_OK );

if( -1 == ListView_InsertItem( GetDlgItem( hWnd, IDC_LIST1 ), &lvi ) )
MessageBoxW( nullptr, L"可乐木木", L"可乐木木", MB_OK );

View the full article
 
Back
Top