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. CListCtrl and selected rows in a dialog

CListCtrl and selected rows in a dialog

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 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.
  • P Offline
    P Offline
    Peter Jones
    wrote on last edited by
    #1

    I've got a CListCtrl in a dialog that selects a row. The problem is that the selection disappears when I click on a another control in the dialog and the focus moves there. How can I make the CListCtrl continually show the selected row, without going to custom draw, etc? Thanks. Peter

    N 1 Reply Last reply
    0
    • P Peter Jones

      I've got a CListCtrl in a dialog that selects a row. The problem is that the selection disappears when I click on a another control in the dialog and the focus moves there. How can I make the CListCtrl continually show the selected row, without going to custom draw, etc? Thanks. Peter

      N Offline
      N Offline
      Nick Blumhardt
      wrote on last edited by
      #2

      modify the List Control to use LVS_EX_SHOWSELALWAYS, eg void MyDialog::OnInitDialog () { ... m_myList.SetExtendedStyle (m_myList.GetExtendedStyle() | LVS_EX_SHOWSELALWAYS); ... } hope this is what you need nb

      P 1 Reply Last reply
      0
      • N Nick Blumhardt

        modify the List Control to use LVS_EX_SHOWSELALWAYS, eg void MyDialog::OnInitDialog () { ... m_myList.SetExtendedStyle (m_myList.GetExtendedStyle() | LVS_EX_SHOWSELALWAYS); ... } hope this is what you need nb

        P Offline
        P Offline
        Peter Jones
        wrote on last edited by
        #3

        Thanks, that pointed me in the right direction. It doesn't quite work that way, so I need to do something like this: CMyDialog:OnInitDialog... CRect rcWin; m_ListCtrl.GetWindowRect(&rcWin); ScreenToClient(&rcWin); DWORD nStyle = m_ListCtrl.GetStyle(); UINT nID = ::GetWindowLong(m_ListCtrl.m_hWnd,GWL_ID); long nExStyle = m_ListCtrl.GetExtendedStyle(); m_ListCtrl.DestroyWindow(); m_ListCtrl.Create(nStyle | WS_BORDER | LVS_SHOWSELALWAYS, rcWin, this, nID); m_ListCtrl.SetExtendedStyle(nExStyle | WS_EX_WINDOWEDGE); Still haven't figured out how to get the standard 3-d border on the listcontrol. Tried all sorts of WS_ and WS_EX_ but it doesn't seem to go. May have to leave it that way. Peter

        T 1 Reply Last reply
        0
        • P Peter Jones

          Thanks, that pointed me in the right direction. It doesn't quite work that way, so I need to do something like this: CMyDialog:OnInitDialog... CRect rcWin; m_ListCtrl.GetWindowRect(&rcWin); ScreenToClient(&rcWin); DWORD nStyle = m_ListCtrl.GetStyle(); UINT nID = ::GetWindowLong(m_ListCtrl.m_hWnd,GWL_ID); long nExStyle = m_ListCtrl.GetExtendedStyle(); m_ListCtrl.DestroyWindow(); m_ListCtrl.Create(nStyle | WS_BORDER | LVS_SHOWSELALWAYS, rcWin, this, nID); m_ListCtrl.SetExtendedStyle(nExStyle | WS_EX_WINDOWEDGE); Still haven't figured out how to get the standard 3-d border on the listcontrol. Tried all sorts of WS_ and WS_EX_ but it doesn't seem to go. May have to leave it that way. Peter

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Instead of re-creating the window, select the 'show selection always' option in the list control properties in dialog editor. > Still haven't figured out how to get the standard 3-d border on > the listcontrol. Tried all sorts of WS_ and WS_EX_ but > it doesn't seem to go Are you creating your list control programatically (CListCtrl::Create), or in dialog editor? Tomasz Sowinski http://www.shooltz.com.pl

          P 1 Reply Last reply
          0
          • T Tomasz Sowinski

            Instead of re-creating the window, select the 'show selection always' option in the list control properties in dialog editor. > Still haven't figured out how to get the standard 3-d border on > the listcontrol. Tried all sorts of WS_ and WS_EX_ but > it doesn't seem to go Are you creating your list control programatically (CListCtrl::Create), or in dialog editor? Tomasz Sowinski http://www.shooltz.com.pl

            P Offline
            P Offline
            Peter Jones
            wrote on last edited by
            #5

            Yes, that's exactly what I was looking for. Thanks! Peter

            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