首页 > 其他 > 详细

MFC CListView

时间:2014-03-31 06:25:00      阅读:491      评论:0      收藏:0      [点我收藏+]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
void CMyListView::InitializeListView()
{
    /*
    CListCtrl& m_list = GetListCtrl();//得到内置 listctrl 引用   
    LONG lStyle;   
    lStyle = GetWindowLong(m_list.m_hWnd, GWL_STYLE);//获得当前窗口风格
    lStyle &= ~LVS_TYPEMASK; //清除显示方式  
    lStyle |= LVS_REPORT; //设置窗口风格 
    SetWindowLong(m_list.m_hWnd, GWL_STYLE, lStyle); //设置窗口风格
    DWORD dwStyle = m_list.GetExtendedStyle(); 
    //???D?3ò?DDê±ê1??DD??áá(??ê?ó?óú±¨±í·???μ? listctrl)  
    dwStyle |= LVS_EX_FULLROWSELECT;   
    dwStyle |= LVS_EX_GRIDLINES;//í?????(??êêó?óú±¨±í·???listctrl) 
    m_list.SetExtendedStyle(dwStyle); //设置扩展风格 
    m_list.SetBkColor(RGB(200, 200, 200)); //设置背景颜色
    m_list.SetTextBkColor(RGB(200, 200, 200)); //设置文字背景颜色  
    m_list.SetTextColor(RGB(10, 10, 80)); //设置文字颜色 
    //插入标题 
    m_list.InsertColumn( 0, "Name", LVCFMT_CENTER, 80 );   
    m_list.InsertColumn( 1, "ID Number", LVCFMT_CENTER, 110 ); 
    m_list.InsertColumn( 2, "Sex", LVCFMT_CENTER, 110 );
    */
    CWaitCursor wc;
    CListCtrl& theListCtrl = GetListCtrl();
    theListCtrl.SetRedraw(FALSE);
    //For the style LVS_EX_FULLROWSELECT, you‘ll need the following, depending on the OS:
    //Windows NT: Requires version 5.0 or later (or version 4.0 with Internet Explorer 3.0 and later)..
    //Windows: Requires Windows 98 (or Windows 95 with Internet Explorer 3.0 or later).
    //Otherwise, you‘ll need to do ownerdrawn stuff. In that case, see the MFC ROWLIST sample.
    DWORD dwExStyle = LVS_EX_FULLROWSELECT;
    theListCtrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, (WPARAM)dwExStyle, (LPARAM)dwExStyle);
    COLORREF crYellow = RGB(240,240,200); //light yellow
    theListCtrl.SetBkColor(crYellow);
    theListCtrl.SetTextBkColor(crYellow);
    theListCtrl.InsertColumn(0, "name");
    theListCtrl.InsertColumn(1, "address");
    theListCtrl.InsertColumn(2, "city");
    theListCtrl.InsertColumn(3, "state");
    theListCtrl.InsertColumn(4, "zip code");
    for(UINT i = 0; i< 5; i++)
        theListCtrl.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);//根据行的字符串的宽度确定行的宽度
    theListCtrl.SetRedraw(TRUE);
    theListCtrl.Invalidate();
}

  

MFC CListView,布布扣,bubuko.com

MFC CListView

原文:http://www.cnblogs.com/thetung/p/3634982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!