Use listctrl in VC to save the socket handle of the online host

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.