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){

        ......

   }

发布了90 篇原创文章 · 获赞 3 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/sunnyboychina/article/details/4675133