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. Problem changing styles in CListView

Problem changing styles in CListView

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiowpfhelp
4 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.
  • I Offline
    I Offline
    ijprest
    wrote on last edited by
    #1

    I created an app with the MFC AppWizard (in VS.net), and chose the "explorer-style project" option, which creates two panes---a TreeView on the left, and a ListView on the right. The wizard also generates a toolbar with buttons for each of the ListView styles (icon, small icon, list, and report), and the necessary code to change between the styles (via the ModifyStyle function). Unfortunately, it doesn't work. Oh, the style does get changed. I even get the OnStyleChanged notification. But the ListView doesn't change styles. (I can change the initial style in PreCreateWindow, but I want to do it dynamically.) The only changes made to the AppWizard-generated application were to add a few items to the listbox (in OnInitialUpdate): GetListCtrl().InsertColumn(0, "foo"); GetListCtrl().InsertItem(0, "aaa"); GetListCtrl().InsertItem(1, "bbb"); GetListCtrl().InsertItem(2, "ccc"); What's going on? Am I missing something really obvious? Thanks,

    H 1 Reply Last reply
    0
    • I ijprest

      I created an app with the MFC AppWizard (in VS.net), and chose the "explorer-style project" option, which creates two panes---a TreeView on the left, and a ListView on the right. The wizard also generates a toolbar with buttons for each of the ListView styles (icon, small icon, list, and report), and the necessary code to change between the styles (via the ModifyStyle function). Unfortunately, it doesn't work. Oh, the style does get changed. I even get the OnStyleChanged notification. But the ListView doesn't change styles. (I can change the initial style in PreCreateWindow, but I want to do it dynamically.) The only changes made to the AppWizard-generated application were to add a few items to the listbox (in OnInitialUpdate): GetListCtrl().InsertColumn(0, "foo"); GetListCtrl().InsertItem(0, "aaa"); GetListCtrl().InsertItem(1, "bbb"); GetListCtrl().InsertItem(2, "ccc"); What's going on? Am I missing something really obvious? Thanks,

      H Offline
      H Offline
      Hydralisk
      wrote on last edited by
      #2

      DWORD dwStyle; dwStyle=::GetWindowLong(this->m_hWnd,GWL_STYLE); dwStyle|=LVS_REPORT; ::SetWindowLong(this->m_hWnd,GWL_STYLE,dwStyle); To change extent style,use GWL_EXSYTLE. Hope it helps you!

      I 1 Reply Last reply
      0
      • H Hydralisk

        DWORD dwStyle; dwStyle=::GetWindowLong(this->m_hWnd,GWL_STYLE); dwStyle|=LVS_REPORT; ::SetWindowLong(this->m_hWnd,GWL_STYLE,dwStyle); To change extent style,use GWL_EXSYTLE. Hope it helps you!

        I Offline
        I Offline
        ijprest
        wrote on last edited by
        #3

        Thanks for the reply, but this unfortunately doesn't work. Note that the AppWizard already generated code to change the style (using ModifyStyle). The appropriate style DWORD does get changed. The problem is that the ListView doesn't respond to changing the style. No matter what I change the style to, I can't effect any changes in the actual control. Any help is appreciated.

        I 1 Reply Last reply
        0
        • I ijprest

          Thanks for the reply, but this unfortunately doesn't work. Note that the AppWizard already generated code to change the style (using ModifyStyle). The appropriate style DWORD does get changed. The problem is that the ListView doesn't respond to changing the style. No matter what I change the style to, I can't effect any changes in the actual control. Any help is appreciated.

          I Offline
          I Offline
          ijprest
          wrote on last edited by
          #4

          Got it! Turns out all you need to do is call the base class in your OnStyleChanged handler (or remove it the handler altogether). It's somewhat strange that the AppWizard-generated code would override OnStyleChanged but not have it call the base class.

          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