LISTVIEW_SetItemBitmap

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • LISTVIEW_SetItemBitmap

      Hi all.
      I have an issue regarding the creation of a page with emWin that is using LISTVIEW_SetItemBitmap.

      I want to put all bitmap on flash filesystem and load them one by one with LISTVIEW_SetItemBitma.

      The fact is that the function require a (const GUI_BITMAP *) so I create a SRAM buffer with this structure that I use as temporary storage.

      So the code looks like:
      guiGenData = GUIResourceLoadBitmap( image1 ) ;

      LISTVIEW_SetItemBitmap( hListId, 0, row, 0, 0, (const GUI_BITMAP *)&guiGenData );



      guiGenData = GUIResourceLoadBitmap( image2 ) ;

      LISTVIEW_SetItemBitmap( hListId, 0, row, 0, 0, (const GUI_BITMAP *)&guiGenData );

      guiGenData = GUIResourceLoadBitmap( image3 ) ;

      LISTVIEW_SetItemBitmap( hListId, 0, row, 0, 0, (const GUI_BITMAP *)&guiGenData );


      When the page is create I see that all images are equal to image3. What's the matter?

      Thanks in advance,
      Marco Crivellari
    • Hi Marco,

      all bitmap pointers you set must be valid the whole time you use them. Since you use the same pointer every time, all item bitmaps now point to the same address (which is the one from when you last loaded the bitmap).
      To solve this, simply use different pointer variables for each different bitmap.

      After you don't need the bitmaps anymore, e.g. after you deleted the window, the pointers don't have to be valid anymore.

      Best regards,

      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.