发送消息!!!!!List Boxes:Another handy control is the list box. This is the last standard control that I'm going to cover for now, cause frankly they aren't that interesting, and if you aren't bored yet well, I am :)Adding Items:The first thing you'll want to do with a listbox is add items to it. int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)"Hi there!");As you can see, this is a pretty simple task. If the listbox has the LBS_SORT style, the new item will be added in alphabetical order, otherwise it will just be added to the end of the list. This message returns the index of the new item either way, and we can use this to perform other tasks on the item,such as associating some data with it. Usually this will be things like a pointer to a struct containing more information, or maybe an ID that you will use to identify the item, it's up to you. SendDlgItemMessage(hwnd, IDC_LIST, LB_SETITEMDATA, (WPARAM)index, Standard Controls: Button, Edit, List Box, Static (LPARAM)nTimes);
其他的可以用GetDlgItem得到句柄后用SendMessage
str = "你好";
SendMessage(GetDlgItem(hwnd,IDC_LIST1),LB_ADDSTRING,0,LPARAM(str));
they aren't that interesting, and if you aren't bored yet well, I am :)Adding Items:The first thing you'll want to do with a listbox is add items to it.
int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)"Hi
there!");As you can see, this is a pretty simple task. If the listbox has the LBS_SORT style, the new item will be added in alphabetical order, otherwise it will just be added to the end of the list.
This message returns the index of the new item either way, and we can use this to perform other tasks on the item,such as associating some data with it. Usually this will be things like a pointer to a struct containing more
information, or maybe an ID that you will use to identify the item, it's up to you.
SendDlgItemMessage(hwnd, IDC_LIST, LB_SETITEMDATA, (WPARAM)index,
Standard Controls: Button, Edit, List Box, Static
(LPARAM)nTimes);
list box还是不行的