home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / mswindo / programm / misc / 3310 < prev    next >
Encoding:
Text File  |  1992-11-09  |  1.8 KB  |  67 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!mcsun!sunic!ugle.unit.no!nuug!dhhalden.no!pc225.dhhalden.no!runehh
  3. From: runehh@dhhalden.no (RUNE HALFDAN HOLST HUSEBY)
  4. Subject: How to force selection of item in combo-box (OWL)
  5. Message-ID: <runehh.99.721270011@dhhalden.no>
  6. Keywords: combo, OWL
  7. Lines: 54
  8. Sender: news@dhhalden.no (Network News User)
  9. Nntp-Posting-Host: pc225
  10. Organization: Ostfold College
  11. Date: Mon, 9 Nov 1992 00:46:51 GMT
  12.  
  13. In a project I'm currently working, I put several things into a drop-down 
  14. combo-box as the user types something.
  15. Later I need to traverse the items in the combo-box, so I thought it would 
  16. be easy to force selection of item nr 1, then nr 2 and so forth, getting the 
  17. text from each selected item.
  18.  
  19. Im using Borlands OWL-library.
  20.  
  21. // code 
  22. void WCompose::generate_envelope(void)
  23. {
  24.     char szRecipient[20];
  25.     int nIndex = 0;
  26.  
  27. // pComboTo is a pointer to a TComboBox
  28.  
  29.   // Selects first in list 
  30.  
  31. // This is the test that fails
  32.     if(pComboTo->SetSelIndex(nIndex) < 0)
  33.     {
  34.         MessageBeep (-1);
  35.         BWCCMessageBox (HWindow, "Enter names to send to!", NULL, 
  36.                 MB_OK | MB_ICONSTOP);        
  37.         return;
  38.     }
  39.  
  40.     do
  41.     {
  42.         pComboTo->GetText(szRecipient, 20);
  43.         pComboTo->GetString (szRecipient, nIndex);
  44.         // do something with text
  45.         // Selects first in list
  46.         nIndex++;
  47.  
  48.         if(pComboTo->SetSelIndex(nIndex) < 0)
  49.         {
  50.             // No more to send to
  51.             break;
  52.         }
  53.  
  54.         generate_recipients();
  55.     }
  56.     while (1);
  57. }
  58.  
  59. What I'm trying to do, is first select item index 0, put the item into a 
  60. string, use it, select next item, until SetSelIndex(nIndex) returns 
  61. something less than 0 because there is no more items to be selected.
  62. For some reason, my first SetSelIndex(nIndex) fails for some unknown reason.
  63. I'm absolutely positive that there is something in the combobox.
  64.  
  65. Thanks for any help!
  66.  
  67.