List box的使用

//List Box內容的建立  

for ( int n = 0; n < count; n++) {
    // LB_INSERTSTRING Message

    // Inserts a string or item data into a list box.

    // lResult = SendMessage( hWndControl,            LB_INSERTSTRING,       wParam,                lParam     );

    //     wParam : The zero-based index of the position at which to insert the string.

    //     lParam   :  A pointer to the null-terminated string to be inserted.

    SendDlgItemMessage(hwnd, IDC_HvE01NSPRT_COMBO_KINMU,
     CB_INSERTSTRING, (WPARAM)setDataCount, (LPARAM)pData[n].name);  //插入列表一行的文字

 

    // LB_SETITEMDATA Message

    // Sets a value associated with the specified item in a list box.

    // lResult = SendMessage( hWndControl,            LB_SETITEMDATA,       wParam,                lParam     );

    //     wParam : Specifies the zero-based index of the item.

    //     lParam   : Specifies the value to be associated with the item.

    iItemData = atoi(pData[n].code);

    SendDlgItemMessage(hwnd, IDC_HvE01NSPRT_COMBO_KINMU,
     CB_SETITEMDATA, (WPARAM)setDataCount, (LPARAM)iItemData);           //設定所插入行的代表數值
    setDataCount++;
   }
  }


//List Box的使用

    // LB_GETCURSEL Message

    // Gets the index of the currently selected item, if any, in a single-selection list box.

    // lResult = SendMessage( hWndControl,            LB_GETCURSEL,       wParam,                lParam     );

    //     wParam : Not used; must be zero.

    //     lParam   : Not used; must be zero.

   no = SendDlgItemMessage(hwnd, IDC_HvE01NSPRT_LIST_SHEET,
          LB_GETCURSEL, (WPARAM)0, (LPARAM)0);      //取得選擇項的索引
   

    // LB_GETITEMDATAMessage

    // Gets the application-defined value associated with the specified list box item.

    // lResult = SendMessage( hWndControl,            LB_GETITEMDATA,       wParam,                lParam     );

    //     wParam : The index of the item.

    //     lParam   : Not used; must be zero.

   retNo = SendDlgItemMessage(hwnd, IDC_HvE01NSPRT_LIST_SHEET, LB_GETITEMDATA,
          (WPARAM)no, (LPARAM)0);                              //取得選擇行的代表數值,即上面SETITEMDATA設定的值
   switch(retNo){

        ......

   }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章