www.pudn.com > VX.rar > MyBarLeftBottom.cpp
// MyBarLeftBottom.cpp : implementation file
//
#include "stdafx.h"
#include "MyBarLeftBottom.h"
#include "Resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyBarLeftBottom
CMyBarLeftBottom::CMyBarLeftBottom()
{
// TODO: add construction code here.
}
CMyBarLeftBottom::~CMyBarLeftBottom()
{
// TODO: add destruction code here.
}
BEGIN_MESSAGE_MAP(CMyBarLeftBottom, CCJControlBar)
//{{AFX_MSG_MAP(CMyBarLeftBottom)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyBarLeftBottom message handlers
static int _gColText[] = { IDS_COL_1, IDS_COL_2 ,IDS_COL_3};
static int _gColSize[] = { 120, 180 ,180};
int CMyBarLeftBottom::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CCJControlBar::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (!m_ListCtrl.Create (WS_TABSTOP|WS_CHILD|WS_VISIBLE|LVS_REPORT,
CRect(0,0,0,0), this, IDC_LIST_CTRL_1))
{
TRACE0("Failed to create view for CMyBarLeft\n");
return -1;
}
SetChild(&m_ListCtrl);
m_ListCtrl.ModifyStyleEx(0, WS_EX_STATICEDGE);
BuildColumns(3, _gColSize, _gColText);
for(int i=0;i<3;i++) {
m_ListCtrl.InsertItem(i,"潘立群" );
m_ListCtrl.SetItem(i,1,LVIF_TEXT,"http://summerplq.51.net",
0,LVIF_TEXT,LVIF_TEXT,0);
m_ListCtrl.SetItem(i,2,LVIF_TEXT,"aulee@vip.sina.com",
0,LVIF_TEXT,LVIF_TEXT,0);
}
for(int j=3;j<6;j++) {
m_ListCtrl.InsertItem(j,"立群.潘" );
m_ListCtrl.SetItem(j,1,LVIF_TEXT,"http://summerplq.51.net",
0,LVIF_TEXT,LVIF_TEXT,0);
m_ListCtrl.SetItem(j,2,LVIF_TEXT,"即将推出完全XP风格界面",
0,LVIF_TEXT,LVIF_TEXT,0);
}
return 0;
}
void CMyBarLeftBottom::BuildColumns(int nCols, int * nWidth, int * iCol)
{
ASSERT(nCols);
ASSERT(nWidth);
ASSERT(iCol);
ASSERT(m_ListCtrl);
//insert columns
int i;
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
CString strTemp;
for(i = 0; i < nCols; i++)
{
lvc.iSubItem = i;
strTemp.LoadString(iCol[i]);
lvc.pszText = (char*)(LPCTSTR)strTemp;
lvc.cx = nWidth[i];
lvc.fmt = LVCFMT_LEFT;
m_ListCtrl.InsertColumn(i,&lvc);
}
}