CListCtrl 혹은 ListView 컨트롤의 Column을 쉽게 초기화 하는 방법

 
LV_COLUMN lvcolumn;
struct
{
    UINT mask;
    char name[MAX_PATH];
    int width;
}COLUMNS[] = {
   { LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH, "", 128 },
   { LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH, "", 128 },
   { LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH, "", 128 },
       ...  // 적당히 알맞게...
};
 
int columns = sizeof(COLUMNS) / sizeof(COLUMNS[0]);
 
for(int i=0;i<columns;i++)
{
    lvcolumn.mask = COLUMNS[i].mask;
    lvcolumn.fmt = LVCFMT_LEFT;
    lvcolumn.pszText = COLUMNS[i].name;
    lvcolumn.iSubItem = i;
    lvcolumn.cx = COLUMNS[i].width;
    m_playList.InsertColumn(i,&lvcolumn);
}
 
 
DWORD dwStyle;
dwStyle = m_ctrlList.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;//|LVS_EX_GRIDLINES ;
m_ctrlList.SetExtendedStyle(dwStyle);
 
 
DWORD dwStyle = ListView_GetExtendedListViewStyle(hWnd);
ListView_SetExtendedListViewStyle(hWnd, dwStyle | LVS_EX_FULLROWSELECT);