smartphone List View 使用日誌

來源:互聯網
上載者:User

建立一個 List View 控制項

// Create ListView

    hwndRet = CreateWindow (WC_LISTVIEW, NULL,

                                    WS_CHILD | 

                                      WS_VISIBLE | 

                                      LVS_REPORT | 

                                      /*LVS_OWNERDATA | */      // 說明 1

                                      LVS_NOCOLUMNHEADER, 

                                      0, 

                                      0, 

                                      mainRect.right - mainRect.left, 

                                      mainRect.bottom - mainRect.top,

                                      hwndPrnt, 

                                      (HMENU)ID_LISTVIEW,    // 控制項 ID

                                     g_hInst, 0);        

 

說明1: 如果建立 ListView 時加上LVS_OWNERDATA 標緻, 系統就不會畫出由 ListView_InsertItem 插入的內容, 程式員要自己在 WM_NOTIFY 處處理. 以下是例子:

 

        case WM_NOTIFY:

            if (ID_LISTVIEW == wParam)            

                return OnListViewNotify(hWnd, lParam);

            break;

 

LRESULT OnListViewNotify(HWND hwnd, LPARAM lParam)

{

    NMHDR* pnmh = (NMHDR*) lParam;

    LRESULT lResult = 0;

 

    switch(pnmh->code)

    {

        case LVN_GETDISPINFO:

            {

                LV_DISPINFO* pdi = (LV_DISPINFO*)lParam;

 

                if(0 == pdi->item.iSubItem)

                {

                    if(pdi->item.mask & LVIF_TEXT)

                    {

                        wcscpy(pdi->item.pszText, L"1213213421");

                        pdi->item.cchTextMax = wcslen(pdi->item.pszText);

                        pdi->item.iItem;

                    }

 

                    if(pdi->item.mask & LVIF_IMAGE)

                    {

                        pdi->item.iImage = 0;

                    }

                }

                else

                {

                    if(pdi->item.mask & LVIF_TEXT)

                    {

                        pdi->item.pszText;

                        pdi->item.cchTextMax;

                        pdi->item.iItem;

                        pdi->item.iSubItem;

                    }

                }

            }

            break;

 

        case LVN_ITEMACTIVATE:

            break;

 

        // Handle this notify if you want to use the number keys to select

        // items in the view (like how the desktop file explorer lets you

        // select files by typing the first few characters of the file name.)

        // This notify is also used then the control is sent an LVM_FINDITEM

        case LVN_ODFINDITEM:

            {

                NMLVFINDITEM* pFindItem = (NMLVFINDITEM*)lParam;

                // Used if you are trying to find an item in the list view

            }

            break;

    }

 

    return(lResult);

}

 

否則相反系統不會發送 WM_NOTIFY 事件. 並會自動畫出由 ListView_InsertItem 添加的內容.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.