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. Items are not visible in a ListBox [modified]

Items are not visible in a ListBox [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlearning
3 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.
  • E Offline
    E Offline
    Elsie
    wrote on last edited by
    #1

    In ListBox i'm using it to display the Strings, After adding it to resource it's property is set as ownerdraw fixed and Single selection When i create an object of it, as CCheckListBox the items are being displayed, but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible. I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function. But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible. void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (lpDrawItemStruct->itemID == (UINT)-1) { // Draws item text int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top; pDC->SetBkMode(TRANSPARENT); lpDrawItemStruct->rcItem.left += h; int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT); } } What's the wrong/ or missing? Would Appreciate any help

    modified on Sunday, January 25, 2009 11:40 PM

    H 1 Reply Last reply
    0
    • E Elsie

      In ListBox i'm using it to display the Strings, After adding it to resource it's property is set as ownerdraw fixed and Single selection When i create an object of it, as CCheckListBox the items are being displayed, but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible. I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function. But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible. void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (lpDrawItemStruct->itemID == (UINT)-1) { // Draws item text int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top; pDC->SetBkMode(TRANSPARENT); lpDrawItemStruct->rcItem.left += h; int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT); } } What's the wrong/ or missing? Would Appreciate any help

      modified on Sunday, January 25, 2009 11:40 PM

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      Do you specify LBS_HASSTRINGS (checkbox in resource editor)?

      Best wishes, Hans


      [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

      E 1 Reply Last reply
      0
      • H Hans Dietrich

        Do you specify LBS_HASSTRINGS (checkbox in resource editor)?

        Best wishes, Hans


        [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

        E Offline
        E Offline
        Elsie
        wrote on last edited by
        #3

        yes, LBS_OWNERDRAWFIXED ,LBS_HASSTRINGS is being specified

        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