Use listctrl in VC to save the socket handle of the online host
I know that the list box in BCB has a date item. In the group last night, the VC listctrl can also be saved to
I am very happy with the DWORD type data, because at that time I was a headache for how to handle the socket list of online hosts,
The socket is of the unsigned long type. That is to say, the online host can be stored in listctrl, and this method can be used to solve the problem.
Save socket data
Int num = m_list.insertitem (imageid, szip, imageid );
M_list.setitemdata (Num, (DWORD) client); // Save the service socket handle
In this way, connect the socket handle to the list item.
Obtain socket data
Add a click message to the list. When receiving the message, retrieve the socket value and set it to the current socket. The Code is as follows:
Void cmydlg: onclicklist (nmhdr * pnmhdr, lresult * presult)
{
Position Pos = m_list.getfirstselecteditemposition ();
Int currentselect = m_list.getnextselecteditem (POS); // obtain the current selected item
If (currentselect> = 0)
{
DWORD val;
Val = m_list.getitemdata (currentselect); // get the data
Currentserversocket = (socket) val; // convert to socket
}
* Presult = 0;
}