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. About multi-column listbox

About multi-column listbox

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingwpfquestion
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.
  • C Offline
    C Offline
    Chen XuNuo
    wrote on last edited by
    #1

    I am doing a multi-column listbox,I set its styles:OwnerDraw-Fixed,Multi-column and "No integal height".Then I add virtual function MeasureItem and add code : void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) { // TODO: Add your code to determine the size of specified item CRect rect; GetWindowRect(&rect); ScreenToClient(&rect); lpMeasureItemStruct->itemHeight=rect.Height()/2; lpMeasureItemStruct->itemWidth=rect.Width()/4; } I add a member function to initialize the data and call this function in PreSubclassWindow: void CColorListBox::InitData() { SetItemData(0,RGB(255,0,0)); SetItemData(1,RGB(0,255,0)); SetItemData(2,RGB(0,0,255)); SetItemData(3,RGB(125,0,0)); SetItemData(4,RGB(0,125,0)); SetItemData(5,RGB(0,0,125)); SetItemData(6,RGB(125,125,0)); SetItemData(7,RGB(125,125,125)); } The last I do DrawItem: void CColorListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); UINT action=lpDrawItemStruct->itemAction; UINT state=lpDrawItemStruct->itemState; CRect rcItem=lpDrawItemStruct->rcItem; //pDC->SetBkMode(TRANSPARENT); if( !(state&ODS_SELECTED) ) pDC->FillSolidRect(&rcItem,(COLORREF)lpDrawItemStruct->itemData); } Is there something wrong in my operation?I set a breakpoint in MeasureItem and debug the program,but it don't run through the breakpoint? I appreciate your comments~

    C 1 Reply Last reply
    0
    • C Chen XuNuo

      I am doing a multi-column listbox,I set its styles:OwnerDraw-Fixed,Multi-column and "No integal height".Then I add virtual function MeasureItem and add code : void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) { // TODO: Add your code to determine the size of specified item CRect rect; GetWindowRect(&rect); ScreenToClient(&rect); lpMeasureItemStruct->itemHeight=rect.Height()/2; lpMeasureItemStruct->itemWidth=rect.Width()/4; } I add a member function to initialize the data and call this function in PreSubclassWindow: void CColorListBox::InitData() { SetItemData(0,RGB(255,0,0)); SetItemData(1,RGB(0,255,0)); SetItemData(2,RGB(0,0,255)); SetItemData(3,RGB(125,0,0)); SetItemData(4,RGB(0,125,0)); SetItemData(5,RGB(0,0,125)); SetItemData(6,RGB(125,125,0)); SetItemData(7,RGB(125,125,125)); } The last I do DrawItem: void CColorListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); UINT action=lpDrawItemStruct->itemAction; UINT state=lpDrawItemStruct->itemState; CRect rcItem=lpDrawItemStruct->rcItem; //pDC->SetBkMode(TRANSPARENT); if( !(state&ODS_SELECTED) ) pDC->FillSolidRect(&rcItem,(COLORREF)lpDrawItemStruct->itemData); } Is there something wrong in my operation?I set a breakpoint in MeasureItem and debug the program,but it don't run through the breakpoint? I appreciate your comments~

      C Offline
      C Offline
      Chen XuNuo
      wrote on last edited by
      #2

      The problem has been solved~ Thanks~

      H 1 Reply Last reply
      0
      • C Chen XuNuo

        The problem has been solved~ Thanks~

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        You can share your answer;)


        WhiteSky


        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