리스트 컨트롤

Untitled

Report 컨트롤 구조

ListView_InsertColumn()

void ListView_InsertColumn(
   HWND hwnd,
   int iCol,
   const LPLVCOLUMN pcol
);

LPLVCOLUMN 구조체

typedef struct tagLVCOLUMNA {
  UINT  mask;               // 컬럼에 적용할 속성을 결정. 비트 OR 연산을 통해 조합해줌.
  int   fmt;                // 컬럼과 서브 아이템의 데이터 정렬 형식을 지정함.
  int   cx;                 // 컬럼의 가로 길이.
  LPSTR pszText;            // 컬럼 정보 문자열.
  int   cchTextMax;
  int   iSubItem;           // 서브 아이템 인덱스.
  int   iImage;
  int   iOrder;
  int   cxMin;
  int   cxDefault;
  int   cxIdeal;
} LVCOLUMNA, *LPLVCOLUMNA;
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND hListBox;
    static const wchar_t* strMenu[] = { L"메뉴1", L"메뉴2", L"메뉴3" };
    LVCOLUMN lvColumn;

    UNREFERENCED_PARAMETER(lParam);
    switch (message)
    {
    case WM_INITDIALOG:
        hListBox = GetDlgItem(hDlg, IDC_LIST1);
        lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
        lvColumn.fmt = LVCFMT_CENTER;

        for (int i = 0; i < 3; ++i)
        {
            lvColumn.cx = lstrlenW(strMenu[i]) * 15;
            lvColumn.pszText = const_cast<wchar_t*>(strMenu[i]);
            ListView_InsertColumn(hListBox, i, &lvColumn); // Windowsx에서 제공하는 매크로 함수.
        }
        return (INT_PTR)TRUE;
    case WM_CLOSE:
        EndDialog(hDlg, 0);
        return (INT_PTR)TRUE;
    }
    
    return (INT_PTR)FALSE;
}

Untitled

아이템 관련 매크로 함수

void ListView_GetItemCount(
   HWND hwnd
);