15,900,378 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by william basser (Top 1 by date)
william basser
6-Feb-13 11:11am
View
// TestListViewView.cpp : implementation of the CTestListViewView class
//
#include "stdafx.h"
#include "TestListView.h"
#include "TestListViewDoc.h"
#include "TestListViewView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTestListViewView
IMPLEMENT_DYNCREATE(CTestListViewView, CListView)
BEGIN_MESSAGE_MAP(CTestListViewView, CListView)
ON_COMMAND(ID_EDIT_TEST, &CTestListViewView::OnEditTest)
ON_COMMAND(ID_VIEW_LIST, &CTestListViewView::OnViewList)
ON_COMMAND(ID_VIEW_DETAILS, &CTestListViewView::OnViewDetails)
END_MESSAGE_MAP()
// CTestListViewView construction/destruction
CTestListViewView::CTestListViewView()
{
// TODO: add construction code here
}
CTestListViewView::~CTestListViewView()
{
}
BOOL CTestListViewView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT;
return CListView::PreCreateWindow(cs);
}
void CTestListViewView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl &listTest = GetListCtrl( );
CHeaderCtrl* phdrTest = listTest.GetHeaderCtrl( );
// create a item
HDITEM hdiItem;
hdiItem.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
hdiItem.cxy = 150;
hdiItem.fmt = HDF_STRING | HDF_LEFT;
hdiItem.pszText = _T( "Column1" );
phdrTest->InsertItem( 0, &hdiItem );
hdiItem.pszText = _T( "Column2" );
phdrTest->InsertItem( 1, &hdiItem );
}
// CTestListViewView diagnostics
#ifdef _DEBUG
void CTestListViewView::AssertValid() const
{
CListView::AssertValid();
}
void CTestListViewView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
CTestListViewDoc* CTestListViewView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestListViewDoc)));
return (CTestListViewDoc*)m_pDocument;
}
#endif //_DEBUG
// CTestListViewView message handlers
void CTestListViewView::OnEditTest()
{
// get the list contro
CListCtrl &listTest = GetListCtrl( );
// fill
CString strTemp;
for ( int i = 0; i < 50; i++ )
{
strTemp.Format( _T( "Test: %d" ), i );
listTest.InsertItem( i, strTemp );
strTemp.Format( _T( "Col2: %d" ), i );
listTest.SetItemText( i, 1, strTemp );
}
UpdateData( false );
}
void CTestListViewView::OnViewList()
{
// TODO: Add your command handler code here
LONG lStyle = GetWindowLong( m_hWnd, GWL_STYLE );
lStyle &= ~LVS_TYPEMASK;
lStyle |= LVS_LIST;
SetWindowLong( m_hWnd, GWL_STYLE, lStyle );
}
void CTestListViewView::OnViewDetails()
{
// TODO: Add your command handler code here
LONG lStyle = GetWindowLong( m_hWnd, GWL_STYLE );
lStyle &= ~LVS_TYPEMASK;
lStyle |= LVS_REPORT;
SetWindowLong( m_hWnd, GWL_STYLE, lStyle );
}