Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls
return (ModifyStyle(LVS_TYPEMASK, dwViewType & LVS_TYPEMASK));
}
- From the Resource View tab, display the IDR_MAINFRAME menu. In the View
category, add a separator in the first empty item - Click the next empty field and, in the Properties window, click the ID field. Then
click its arrow to select ID_VIEW_LARGEICON. Set its Caption to Large &Icons - In the same way, set the ID of the next item to ID_VIEW_SMALLICICON and set
its Caption to S&mall Icons - In the same way, set the ID of the next item to ID_VIEW_LIST and set its Caption
to &List - In the same way, set the ID of the next item to ID_VIEW_DETAILS and set its
Caption to &Details - To allow the user to change views, right-click the Large Icons menu item and click
Add Event Handler... - In the Message Type list, accept the COMMAND message. In the Class List, click
the view class. In the Function Handler Name, change the name to
OnViewLargeIcon - Click Add And Edit and implement the message as follows:
void CCountriesView::OnViewLargeIcon()
{
// TODO: Add your command handler code here
if( GetViewType() != LVS_ICON )
SetViewType(LVS_ICON);
}
- In the same way, Add An Event Handler for the Small Icons menu item. Associate
its COMMAND message with the view class. Change its name to
OnViewSmallIcon - Implement it as follows:
void CCountriesView::OnViewSmallicon()
{
// TODO: Add your command handler code here
if( GetViewType() != LVS_SMALLICON )
SetViewType(LVS_SMALLICON);
}
- In the same way, Add An Event Handler for the List menu item. Associate its
COMMAND message with the view class and implement it as follows:
void CCountriesView::OnViewList()
{
// TODO: Add your command handler code here
if( GetViewType() != LVS_LIST )
SetViewType(LVS_LIST);
}
- In the same way, Add An Event Handler for the List menu item. Associate its
COMMAND message with the view class and implement it as follows:
void CCountriesView::OnViewDetails()
{
// TODO: Add your command handler code here
if( GetViewType() != LVS_REPORT )
SetViewType(LVS_REPORT);