CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Question Storing a HANDLE in a CListCtrl

    Can this be done and if so how? Trying to store the handle for each of my threads in a list control that also holds each threads corrisponding connecting ipaddress and port. (they are connecting to socket server connections)

    I want to store the threads handle here so that I can send messages to the correct thread insead of broadcasting to all the threads.

    Thanks
    Tom
    Thanks
    Tom Wright

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Storing a HANDLE in a CListCtrl

    Quote Originally Posted by tawright915
    Storing a HANDLE in a CListCtrl Trying to store the handle for each of my threads in a list control that also holds each threads corrisponding connecting ipaddress and port.
    You mean that you want to store that information with the list control - or with each item of the list control?

  3. #3
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Re: Storing a HANDLE in a CListCtrl

    with each item.

    in my list I (so far) have three IP addresses that I'm connecting too via a thread for each one. I want to store the HANDLE for each thread in another sub-item on my list control.

    Thanks
    Tom
    Thanks
    Tom Wright

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Storing a HANDLE in a CListCtrl

    Quote Originally Posted by tawright915
    in my list I (so far) have three IP addresses that I'm connecting too via a thread for each one. I want to store the HANDLE for each thread in another sub-item on my list control.
    First, you will need to create a class which represents an entry of your list - it will have the three IP addresses and the thread handle as members. Then you can associate pointers to instances of that class to each list control item - either with SetItemData / GetItemData, or as the lParam member of an LVITEM structure (depending on how you create / access the items).

  5. #5
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Re: Storing a HANDLE in a CListCtrl

    instead of creating a class, could I just not store the HANDLE in the LPARAM value for each item in my list?
    Thanks
    Tom Wright

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Storing a HANDLE in a CListCtrl

    Quote Originally Posted by tawright915
    instead of creating a class, could I just not store the HANDLE in the LPARAM value for each item in my list?
    Yes - if the only thing you need to store is the handle. I understood that you also need to store the three IP addresses.

  7. #7
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Re: Storing a HANDLE in a CListCtrl

    Sorry for the confusion. I have a list control with three rows. One row is the IP address. The other is the port and the third will be an ID. So with the ID I can add the handle to the LPARAM value.
    Thanks
    Tom Wright

  8. #8
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Storing a HANDLE in a CListCtrl

    Quote Originally Posted by tawright915
    Sorry for the confusion. I have a list control with three rows.
    Three rows - or three columns?

  9. #9
    Join Date
    Dec 2003
    Posts
    95

    Re: Storing a HANDLE in a CListCtrl

    did you try to use SetItemData

  10. #10
    Join Date
    Sep 2002
    Location
    St.Louis, MO
    Posts
    27

    Re: Storing a HANDLE in a CListCtrl

    Three columns....right? I have three different headers. One that says IP address, one that says Port and a third that says ID.

    Columns go up and down and rows go horizontal. .....Right? I alwys get that confused.


    Stam1...that was what I was planning on doing. Thanks

    I'll try it out and let you guys know how it went.

    Thanks for the help.
    Thanks
    Tom Wright

  11. #11
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Storing a HANDLE in a CListCtrl

    Quote Originally Posted by tawright915
    Three columns....right? I have three different headers. One that says IP address, one that says Port and a third that says ID.
    Ok, so that are columns. Yes, columns are vertical, rows horizontal...

    Quote Originally Posted by tawright915
    So with the ID I can add the handle to the LPARAM value.
    Note that in a list control, the item data is always associated with the entire row, not with the sub items (the additional columns). So you would actually not assign the handle to "the ID", but to the entire item (the row).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured