• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            CListCtrl For Beginners(轉載)

            Posted on 2007-03-07 21:23 Tauruser 閱讀(1716) 評論(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























            中文字幕亚洲综合久久2| 久久精品国产99久久久| 久久综合九色综合久99| 热久久最新网站获取| 国产情侣久久久久aⅴ免费| 国产福利电影一区二区三区久久久久成人精品综合 | 国产精品青草久久久久婷婷| 久久99热国产这有精品| 久久久久久久91精品免费观看| 久久精品www人人爽人人| 深夜久久AAAAA级毛片免费看| 亚洲AV日韩精品久久久久| 99久久国产综合精品成人影院 | 精品人妻伦九区久久AAA片69| 中文国产成人精品久久不卡| 91精品久久久久久无码| 精品熟女少妇a∨免费久久| 亚洲国产精品无码久久一区二区| 国产激情久久久久影院老熟女免费| 久久久这里有精品| 久久激情五月丁香伊人| 国产精品九九久久精品女同亚洲欧美日韩综合区| 精品国产乱码久久久久软件| 久久本道综合久久伊人| 91精品日韩人妻无码久久不卡| 97久久超碰成人精品网站| 一本久久a久久精品亚洲| 久久久久亚洲AV成人网人人网站| 久久久久久国产精品美女| 国产精品美女久久久久av爽 | 久久精品aⅴ无码中文字字幕不卡| segui久久国产精品| 日本久久久久久中文字幕| 91久久精品电影| 久久久久久国产精品美女| 久久久久亚洲爆乳少妇无| 午夜视频久久久久一区| 亚洲国产精品无码久久青草| 亚洲欧美一区二区三区久久| 久久国产免费直播| 国产V综合V亚洲欧美久久|