• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Tauruser

            Enjoy Every Day
            posts - 34, comments - 95, trackbacks - 0, articles - 5
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            CListCtrl For Beginners(轉(zhuǎn)載)

            Posted on 2007-03-07 21:23 Tauruser 閱讀(1711) 評論(0)  編輯 收藏 引用 所屬分類: MFC

            The List Control (MFC CListCtrl class) is the type of control that the Windows Explorer uses for it's right-side pane, but figuring out how to use the control can be a different kind of pain. The control is usually used only in "report view", which provides columns for each item. The following shows the basics of adding data to a List Control:

            ???? int ?Index;
            // ?Insert?columns
            ListCtrl.InsertColumn( 0 ,? " One " ,?LVCFMT_LEFT,? - 1 ,? 0 );
            ListCtrl.InsertColumn(
            1 ,? " Two " ,?LVCFMT_LEFT,? - 1 ,? 1 );
            // ?Insert?first?row
            Index? = ?ListCtrl.InsertItem(LVIF_TEXT,? 0 ,? " One?one " ,? 0 ,? 0 ,? 0 ,?NULL);
            ListCtrl.SetItem(Index,?
            1 ,?LVIF_TEXT,? " One?two " ,? 0 ,? 0 ,? 0 ,?NULL);
            // ?Insert?second?row
            Index? = ?ListCtrl.InsertItem(LVIF_TEXT,? 1 ,? " Two?one " ,? 0 ,? 0 ,? 0 ,?NULL);
            ListCtrl.SetItem(Index,?
            1 ,?LVIF_TEXT,? " Two?two " ,? 0 ,? 0 ,? 0 ,?NULL);
            // ?Set?column?widths?(an?optional?nice?touch)
            ListCtrl.SetColumnWidth( 0 ,?LVSCW_AUTOSIZE);
            ListCtrl.SetColumnWidth(
            1 ,?LVSCW_AUTOSIZE);

            If you are using CListView, then you will need to use something such as the following to access the CListCtrl:

            CListCtrl?&ListCtrl?=?GetListCtrl();

            Note that for these to work, the control must have the "LVS_REPORT" style. For list controls in dialogs, including dialogs for CFormView, this style can be set in the dialog editor. If you are using CListView or you are creating list controls using Create, the style can be set in a PreCreateWindow override, as in:

            BOOL?CDumpView::PreCreateWindow(CREATESTRUCT&?cs)?{
            cs.style?
            |=?LVS_REPORT;
            return?CListView::PreCreateWindow(cs);
            }


            Getting a Count of Columns

            The solution for determining the number of columns is not obvious. You must get the header control from the list control and get the number of items (rows) in the header control. So I suggest putting the following in your header:

            CHeaderCtrl?*GetHeaderCtrl()?const?{return?(CHeaderCtrl*)GetDlgItem(0);};
            int?GetColumnsCount()?const?{return?GetHeaderCtrl()->GetItemCount();};


            Deleting All Columns

            Using GetColumnsCount() from above, it is easy to delete all columns.

            void?CListControl::DeleteAllColumns()?{
            ????
            int?i,?n;
            n?
            =?GetColumnsCount();
            for?(i=0;?i<n;?++i)
            ????DeleteColumn(
            0);
            }

            Confusing Terminology


            Microsoft has made things very confusing because the Platform SDK name for a listbox is "ListBox Control" but MFC programmers usually use "list control" to refer to an instance of the CListCtrl class, which is confusing. Also, the MFC class name for a "List View Control" is CListCtrl and CListView is the view class for it. The MFC class name for a "ListBox Control" is CListBox so we would expect the view class for it to also be CListView except there is not a view class. The following summarizes this.

            Platform SDK name:List Boxes
            Window class name: ListBox (See under "Predefined Controls" in User Controls and the documentation for CreateWindow and CreateWindowEx)
            MFC class name:CListBox
            MFC view class name: none

            Platform SDK name:ListView Control
            Window class name: SysListView32 (use WC_LISTVIEW in source code instead, which is defined as "SysListView32")
            MFC class name:CListCtrl
            MFC view class name:CListView























            久久丫忘忧草产品| 国产精品久久久久久影院| 99热热久久这里只有精品68| 精品国产乱码久久久久久郑州公司 | 久久综合丝袜日本网| 精品久久人人妻人人做精品| 久久亚洲精品国产亚洲老地址| 国产亚洲色婷婷久久99精品| 91亚洲国产成人久久精品| 亚洲色婷婷综合久久| 成人a毛片久久免费播放| 中文字幕无码久久精品青草| 久久国产成人精品麻豆| 中文国产成人精品久久不卡| 久久精品国产99国产精品澳门| 少妇被又大又粗又爽毛片久久黑人| WWW婷婷AV久久久影片| 久久影院午夜理论片无码| 精品久久久久久无码中文野结衣| 国产成人精品综合久久久久 | 99久久99久久精品免费看蜜桃| 久久久久久久久久免免费精品| 国产精品无码久久综合 | 久久精品www| 97久久国产综合精品女不卡| 久久精品国产亚洲7777| 久久综合综合久久综合| 一本色道久久HEZYO无码| 国产综合免费精品久久久| av无码久久久久不卡免费网站| 99久久综合国产精品免费| 狠狠色伊人久久精品综合网| 麻豆精品久久精品色综合| 97久久超碰国产精品2021| 午夜精品久久久久久久| 久久香蕉国产线看观看乱码 | 国产精品99久久久久久猫咪| 久久无码人妻一区二区三区| 久久久久亚洲av无码专区 | 97精品国产97久久久久久免费| 国产精品久久久久蜜芽|