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. Repainting a List Control

Repainting a List Control

Scheduled Pinned Locked Moved C / C++ / MFC
architecturehelpquestion
6 Posts 3 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
    alex__b
    wrote on last edited by
    #1

    Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong? void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... } alex 'Architecture is music frozen in space.'

    L M A 3 Replies Last reply
    0
    • A alex__b

      Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong? void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... } alex 'Architecture is music frozen in space.'

      L Offline
      L Offline
      Laxman Auti
      wrote on last edited by
      #2

      When you return from dialog use the following code for list box

      int numberSelected = GetSelCount();
      if (numberSelected>0)
      {
      int *selIndex = new int[numberSelected];
      GetSelItems( numberSelected, selIndex );
      for (int i=0; i < numberSelected; i++)
      {
      //blah....your code for deselection of item

      	}
      }
      

      :) Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:

      A 1 Reply Last reply
      0
      • A alex__b

        Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong? void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... } alex 'Architecture is music frozen in space.'

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        That code is going to redraw the list 3 times. All you need is one call to RedrawWindow().

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

        A 1 Reply Last reply
        0
        • L Laxman Auti

          When you return from dialog use the following code for list box

          int numberSelected = GetSelCount();
          if (numberSelected>0)
          {
          int *selIndex = new int[numberSelected];
          GetSelItems( numberSelected, selIndex );
          for (int i=0; i < numberSelected; i++)
          {
          //blah....your code for deselection of item

          	}
          }
          

          :) Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:

          A Offline
          A Offline
          alex__b
          wrote on last edited by
          #4

          I'm talking about keeping the selection, and just being able to see it again. alex 'Architecture is music frozen in space.'

          1 Reply Last reply
          0
          • M Michael Dunn

            That code is going to redraw the list 3 times. All you need is one call to RedrawWindow().

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

            A Offline
            A Offline
            alex__b
            wrote on last edited by
            #5

            Mike: I agree. But it doesn't (not one, not even all 3). I see the selection again only if manually I click on one of the list headers. alex 'Architecture is music frozen in space.'

            1 Reply Last reply
            0
            • A alex__b

              Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong? void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... } alex 'Architecture is music frozen in space.'

              A Offline
              A Offline
              alex__b
              wrote on last edited by
              #6

              Anybody?? I'm really stuck with this one. Thanks alex 'Architecture is music frozen in space.'

              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