Switching Views

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.


The list view control supports four different view styles.
The four styles are LVS_ICON , LVS_SMALLICON, LVS_LIST and LVS_REPORT.
To switch between views we have to modify the window style using GetWindowLong()
and SetWindowLong().

	// Switch to report view
	ModifyStyle( LVS_TYPEMASK, LVS_REPORT);

The LVS_TYPEMASK is a bit mask representing the bits for all the view styles.
Here is code for a SetView() member function for an extended list view
control class.

void CMyListCtrl::SetView(DWORD dwView)
{
	ModifyStyle( LVS_TYPEMASK, dwView & LVS_TYPEMASK );
}

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read