Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Bitmap in List control

Bitmap in List control

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anu_Bala
    wrote on last edited by
    #1

    Hi, In my dialog bar i added one List control and added few colums and i add datas to that.In first colum i have to add image.But i cannot do that.Just i pasted the code..Pls see that and clear my problem. In Oncreate i added list control to dialog bar.

    if (!m_RecentAlarms.oAlrmCombo.Create(LVS_REPORT|LVS_SHAREIMAGELISTS,rect,&m_RecentAlarms, ID_RECENTLIST))
    {
    TRACE0("Failed to create Listctrl\n");
    return FALSE;
    }

    	m\_RecentAlarms.oAlrmCombo.InsertColumn(0, "", LVCFMT\_LEFT ,30);
    	m\_RecentAlarms.oAlrmCombo.InsertColumn(1, "Date&Time", LVCFMT\_LEFT ,200);
    	m\_RecentAlarms.oAlrmCombo.InsertColumn(2, "Location Tag", LVCFMT\_LEFT ,50);
    	m\_RecentAlarms.oAlrmCombo.InsertColumn(3, "Location Item", LVCFMT\_LEFT ,50);
    	m\_RecentAlarms.oAlrmCombo.InsertColumn(4, "Source", LVCFMT\_LEFT , 200);	
    	m\_RecentAlarms.oAlrmCombo.InsertColumn(5, "Condition", LVCFMT\_LEFT ,150);			
    
    	m\_RecentAlarms.oAlrmCombo.ShowWindow(SW\_SHOW);
    

    And then i added the datas like this

    POSITION pos = oSysAlarmList.FindIndex(fIndex);
    while(pos)
    {
    ....
    ... //Some coding,im getting data from CPtrList
    ...
    CImageList m_SmallImg;
    m_SmallImg.Create(IDB_ALARM_IMG, 16, 0, RGB(65, 65, 65));
    m_rcntlist->SetImageList(&m_SmallImg, LVSIL_NORMAL);

    	int nIndex = m\_rcntlist->InsertItem(0,"Alarm",0);
    	m\_rcntlist->SetItemText(nIndex,1,objAlarm->tAlmdisTime.Format("%d/%m/%y  %H:%M:%S"));
    	m\_rcntlist->SetItemText(nIndex,2,"");
    	m\_rcntlist->SetItemText(nIndex,3,"");
    	m\_rcntlist->SetItemText(nIndex,4,pTag->GetTagName());
    	m\_rcntlist->SetItemText(nIndex,5,objAlarm->sStatus);  
    

    }

    All texts are coming,only the images are not coming,I have three images in single bitmap ID file.Form that, depends on the alarm status i have to show images,if alarm is high i have to show red alarm.. Pls help me.

    Anu

    D 1 Reply Last reply
    0
    • A Anu_Bala

      Hi, In my dialog bar i added one List control and added few colums and i add datas to that.In first colum i have to add image.But i cannot do that.Just i pasted the code..Pls see that and clear my problem. In Oncreate i added list control to dialog bar.

      if (!m_RecentAlarms.oAlrmCombo.Create(LVS_REPORT|LVS_SHAREIMAGELISTS,rect,&m_RecentAlarms, ID_RECENTLIST))
      {
      TRACE0("Failed to create Listctrl\n");
      return FALSE;
      }

      	m\_RecentAlarms.oAlrmCombo.InsertColumn(0, "", LVCFMT\_LEFT ,30);
      	m\_RecentAlarms.oAlrmCombo.InsertColumn(1, "Date&Time", LVCFMT\_LEFT ,200);
      	m\_RecentAlarms.oAlrmCombo.InsertColumn(2, "Location Tag", LVCFMT\_LEFT ,50);
      	m\_RecentAlarms.oAlrmCombo.InsertColumn(3, "Location Item", LVCFMT\_LEFT ,50);
      	m\_RecentAlarms.oAlrmCombo.InsertColumn(4, "Source", LVCFMT\_LEFT , 200);	
      	m\_RecentAlarms.oAlrmCombo.InsertColumn(5, "Condition", LVCFMT\_LEFT ,150);			
      
      	m\_RecentAlarms.oAlrmCombo.ShowWindow(SW\_SHOW);
      

      And then i added the datas like this

      POSITION pos = oSysAlarmList.FindIndex(fIndex);
      while(pos)
      {
      ....
      ... //Some coding,im getting data from CPtrList
      ...
      CImageList m_SmallImg;
      m_SmallImg.Create(IDB_ALARM_IMG, 16, 0, RGB(65, 65, 65));
      m_rcntlist->SetImageList(&m_SmallImg, LVSIL_NORMAL);

      	int nIndex = m\_rcntlist->InsertItem(0,"Alarm",0);
      	m\_rcntlist->SetItemText(nIndex,1,objAlarm->tAlmdisTime.Format("%d/%m/%y  %H:%M:%S"));
      	m\_rcntlist->SetItemText(nIndex,2,"");
      	m\_rcntlist->SetItemText(nIndex,3,"");
      	m\_rcntlist->SetItemText(nIndex,4,pTag->GetTagName());
      	m\_rcntlist->SetItemText(nIndex,5,objAlarm->sStatus);  
      

      }

      All texts are coming,only the images are not coming,I have three images in single bitmap ID file.Form that, depends on the alarm status i have to show images,if alarm is high i have to show red alarm.. Pls help me.

      Anu

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Anu_Bala wrote:

      CImageList m_SmallImg; m_SmallImg.Create(IDB_ALARM_IMG, 16, 0, RGB(65, 65, 65));

      Is m_SmallImg a member of the same class that the list control belongs to, or just some local variable? Have you tried playing around with different width/height values?

      Anu_Bala wrote:

      All texts are coming,only the images are not coming...

      Where is the code that adds images to the image list?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "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

      "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups