void CTCMShapeModelDlg::InsertItems()
{
HWND hWnd = ::GetDlgItem(m_hWnd, IDC_LIST1);
// Set the LVCOLUMN structure with the required
// column information
LVCOLUMN list;
list.mask = LVCF_TEXT |LVCF_WIDTH|
LVCF_FMT |LVCF_SUBITEM;
list.fmt = LVCFMT_LEFT;
list.cx = 0;
list.pszText = _T(" ");
list.iSubItem = 0;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 5#STD");
list.iSubItem = 0;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 4#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 3#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 2#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 1#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 138.5;
list.pszText = _T(" ");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); for(int i =0;i<8;i++)
{
SetCell(hWnd,_T(" "),i,0);
}
}
void CTCMShapeModelDlg::SetCell(HWND hWnd1,
CString value, int nRow, int nCol)
{
TCHAR szString [256];
wsprintf(szString,value,0);
//Fill the LVITEM structure with the
//values given as parameters.
LVITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nRow;
lvItem.pszText = szString;
lvItem.iSubItem = nCol;
if(nCol>0)
//set the value of listItem
::SendMessage(hWnd1,LVM_SETITEM,
(WPARAM)0,(WPARAM)&lvItem);
else
//Insert the value into List
ListView_InsertItem(hWnd1,&lvItem);
}
{
HWND hWnd = ::GetDlgItem(m_hWnd, IDC_LIST1);
// Set the LVCOLUMN structure with the required
// column information
LVCOLUMN list;
list.mask = LVCF_TEXT |LVCF_WIDTH|
LVCF_FMT |LVCF_SUBITEM;
list.fmt = LVCFMT_LEFT;
list.cx = 0;
list.pszText = _T(" ");
list.iSubItem = 0;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 5#STD");
list.iSubItem = 0;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 4#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 3#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 2#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 104;
list.pszText = _T(" 1#STD");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); list.cx = 138.5;
list.pszText = _T(" ");
list.iSubItem = 2;
//Inserts the column
::SendMessage(hWnd,LVM_INSERTCOLUMN,
(WPARAM)0,(WPARAM)&list); for(int i =0;i<8;i++)
{
SetCell(hWnd,_T(" "),i,0);
}
}
void CTCMShapeModelDlg::SetCell(HWND hWnd1,
CString value, int nRow, int nCol)
{
TCHAR szString [256];
wsprintf(szString,value,0);
//Fill the LVITEM structure with the
//values given as parameters.
LVITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nRow;
lvItem.pszText = szString;
lvItem.iSubItem = nCol;
if(nCol>0)
//set the value of listItem
::SendMessage(hWnd1,LVM_SETITEM,
(WPARAM)0,(WPARAM)&lvItem);
else
//Insert the value into List
ListView_InsertItem(hWnd1,&lvItem);
}
CListCtrl::SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
CListCtrl::InsertColumn()
CListCtrl::InsertItem()
CListCtrl::SetItemText();