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