icons in listview control not working in Windows Mobile 5.0 on a Dell Axim Pocket PC

Hi,

I have written an application for windows mobile 5.0 using Native C++ with MFC in which i have a main Property Page, I have drawn a list view control with type as Report View in this Property Page . I am trying to show an icon with the List view Items, but the image associated with the items are not visible when i add an element to the control though the text is shown properly. I tried using a 16X16 as well as a 32X32 icon, but none seems to work (even with several different color depths (including monochrome)).

I am using the following piece of code

void CPresencePage::OnInitDialog()

{

pImg = new CImageList();

m_list = (CListCtrl*)GetDlgItem(IDC_LIST2);

pImg->Create(32, 32, ILC_COLOR4, 1, 1);

m_list->SetImageList(pImg, LVSIL_NORMAL);

// Add an icon to the imagelist

HICON hIcon =

(HICON)LoadImage(AfxGetResourceHandle(),

MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 32, 32, 0);

pImg->Add(hIcon);

}

void CPresencePage::OnButton1()

{

// Add elements to the list view

m_list->InsertItem(0, TEXT("Hell"), 0);

}

Any help would be appreciated




Answer this question

icons in listview control not working in Windows Mobile 5.0 on a Dell Axim Pocket PC

  • slinnd

    Try converting the images to 16 bits,96 dpi ( i.e the lower quality images ). Have a look at http://blogs.msdn.com/windowsmobile/archive/2006/06/07/621671.aspx about some general guidelines.

    Hope this helps.

    Thanks



  • Wil Burton

    Let's start with error-checking.

    LoadImage returns non-zero on success, CImageList::Add should return non-negative index. Do they



  • programmer01

    Thanks friends

    Problem solved finally, I used bitmap images and the Following piece of code to initialize my imagelist.

    BOOL CPhoneBookDlg::OnInitDialog()

    {

    m_pImgList = new CImageList();

    // Three images in the bitmap 16 * 48

    m_pImgList->Create(16, 16, ILC_COLOR|ILC_MASK, 3, 3);

    CBitmap bmp;

    bmp.LoadBitmapW(IDB_BMP_STATUS1);

    m_pImgList->Add(&bmp, RGB(255, 255, 255));

    m_list->SetImageList(m_pImgList, LVSIL_NORMAL);

    m_list->SetImageList(m_pImgList, LVSIL_SMALL);

    }

    int CPhoneBookDlg::InsertItem(CString str)

    {

    LVITEM lvItem;

    lvItem.mask = LVIF_TEXT | LVIF_IMAGE;

    lvItem.iItem = 0;

    lvItem.iImage = 0;

    lvItem.iSubItem = 0;

    lvItem.pszText = str;

    int nItem = m_list->InsertItem(&lvItem);

    return nItem;

    }

    I think i was using the wrong Image list flag ILC_COLOR4 (for a true color image)

    Anyway thanks a lot for guiding me.



  • caligula

    Yes, LoadImage is successful and so is CImageList::Add, CImage::GetImageCount() also returns the correct number of images loaded, i think there is some issue with the resolution of the image

  • icons in listview control not working in Windows Mobile 5.0 on a Dell Axim Pocket PC