• <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>
            隨筆-60  評論-111  文章-0  trackbacks-0
            msdn原文

            CListCtrl::SortItems

            This method sorts list view items using an application-defined comparison function. The index of each item changes to reflect the new sequence.

            BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD dwData);
            Parameters
            pfnCompare
            Specifies the address of the application-defined comparison function. The comparison function is called during the sort operation each time the relative order of two list items needs to be compared. The comparison function must be either a static member of a class or a standalone function that is not a member of any class.
            dwData
            Specifies the application-defined value that is passed to the comparison function.
            Return Value

            Nonzero if it is successful; otherwise, it is zero. Remarks
            The comparison function has the following form:
            int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, ??LPARAM lParamSort);

            The comparison function must return a negative value if the first item should precede the second, a positive value if the first item should follow the second, or zero if the two items are equivalent.
            The lParam1 and lParam2 parameters specify the item data for the two items being compared. The lParamSort parameter is the same as the dwData value.

            Example


            //?Sort?the?item?in?reverse?alphabetical?order.
            static?int?CALLBACK?
            MyCompareProc(LPARAM?lParam1,?LPARAM?lParam2,?LPARAM?lParamSort)
            {
            ???
            //?lParamSort?contains?a?pointer?to?the?list?view?control.
            ???CListCtrl*?pListCtrl?=?(CListCtrl*)?lParamSort;
            ???CString????strItem1?
            =?pListCtrl->GetItemText(lParam1,?0);
            ???CString????strItem2?
            =?pListCtrl->GetItemText(lParam2,?0);

            ???
            return?strcmp(strItem2,?strItem1);
            }

            void?snip_CListCtrl_SortItems()
            {
            ???
            //?The?pointer?to?my?list?view?control.
            ???extern?CListCtrl*?pmyListCtrl;

            ???
            //?Sort?the?list?view?items?using?my?callback?procedure.
            ???pmyListCtrl->SortItems(MyCompareProc,?(LPARAM)?pmyListCtrl);
            }


            例子中的代碼是不能按照預想的工作的, 因為回調函數接收的2個參數是用SetItemData傳入的值,而不是Item的Index!
            posted on 2007-02-28 22:59 shaker(太子) 閱讀(1823) 評論(3)  編輯 收藏 引用 所屬分類: C++

            評論:
            # re: MSDN的Bug! 2007-03-01 09:07 | mzh
            “The lParam1 and lParam2 parameters specify the item data for the two items being compared.”  回復  更多評論
              
            # re: MSDN的Bug! 2007-03-01 22:49 | shaker
            @mzh
            你看函數用法雖然是這么說明的,
            但是你看例子中的用法是錯了的!  回復  更多評論
              
            # re: MSDN的Bug! 2007-06-06 08:29 | Mickey Mouse
            看來msdn也不是萬能的  回復  更多評論
              
            久久99国产综合精品免费| 2021久久精品免费观看| 精品久久久久久中文字幕| 99久久中文字幕| 久久精品国产一区二区三区| 国产精品亚洲综合久久| 国产精品久久久久久久久鸭| 久久久久人妻精品一区三寸蜜桃| 久久无码AV中文出轨人妻| 久久国产精品77777| 中文字幕精品无码久久久久久3D日动漫 | 久久综合久久综合久久综合| 色诱久久av| 久久成人精品视频| 久久久久av无码免费网| 91久久成人免费| 无码日韩人妻精品久久蜜桃| 亚洲精品tv久久久久久久久久| 国产午夜精品久久久久免费视 | 久久中文字幕人妻熟av女| 久久九九全国免费| 人妻无码久久一区二区三区免费 | 99久久99这里只有免费的精品| 亚洲伊人久久综合影院| 亚洲国产精品久久66| 国产一级持黄大片99久久| 亚洲精品乱码久久久久久| 中文字幕久久精品 | 91麻精品国产91久久久久| 97久久香蕉国产线看观看| 久久精品国产亚洲av日韩| 久久婷婷成人综合色综合| 日韩精品久久无码人妻中文字幕| 老男人久久青草av高清| 热99RE久久精品这里都是精品免费| 欧美精品一区二区久久| 亚洲伊人久久综合影院| 久久丫忘忧草产品| 亚洲国产精品无码久久一区二区| 亚洲伊人久久精品影院 | 国产成人综合久久精品尤物|