Thread: Dialog Boxes

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    Dialog Boxes

    Alright. I have a dialog box. With a list. I want to get the text of one of the entries in the list. The list is IDC_LIST. The handle to IDC_LIST is hList. What function can get a string of a certain entry in that list?

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    No function, you need to send messages to the window.

    This will get line 0 from the listbox:

    Code:
    // Want item 0 (the first item):
    unsigned int listItem = 0; 
    
    
    //First we find out how big it will be:
    unsigned int charCount = ::SendMessage(hList,LB_GETTEXTLEN, (WPARAM) listItem, (LPARAM) 0);
    
    
    // Then allocate enough space for the text plus terminating character:
    TCHAR * buffer = new TCHAR[charCount + 1]; 
    
    
    // Now, try to get the text itself:
    if (::SendMessage(hList,LB_GETTEXT,(WPARAM)listItem,
                     (LPARAM)buffer) == LB_ERR){
      // an error occured.  Handle it here.
    }
    else {
      // We know no error occured.  Do stuff with buffer.
    }
    
    // We allocated string space, so we must free it once we don't need it anymore:
    delete[] buffer;
    Last edited by Cat; 05-22-2003 at 11:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Common Dialog boxes GetOpenFileName()
    By A10 in forum Windows Programming
    Replies: 3
    Last Post: 09-02-2008, 09:56 PM
  2. Dialog Boxes
    By Thantos in forum Windows Programming
    Replies: 7
    Last Post: 08-26-2003, 01:49 PM
  3. Dialog Boxes and Sliders
    By AtomRiot in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 08:36 AM
  4. Dialog Boxes
    By cerion in forum Windows Programming
    Replies: 4
    Last Post: 06-10-2002, 07:54 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM
Website Security Test