home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!mcsun!sunic!ugle.unit.no!nuug!dhhalden.no!pc225.dhhalden.no!runehh
- From: runehh@dhhalden.no (RUNE HALFDAN HOLST HUSEBY)
- Subject: How to force selection of item in combo-box (OWL)
- Message-ID: <runehh.99.721270011@dhhalden.no>
- Keywords: combo, OWL
- Lines: 54
- Sender: news@dhhalden.no (Network News User)
- Nntp-Posting-Host: pc225
- Organization: Ostfold College
- Date: Mon, 9 Nov 1992 00:46:51 GMT
-
- In a project I'm currently working, I put several things into a drop-down
- combo-box as the user types something.
- Later I need to traverse the items in the combo-box, so I thought it would
- be easy to force selection of item nr 1, then nr 2 and so forth, getting the
- text from each selected item.
-
- Im using Borlands OWL-library.
-
- // code
- void WCompose::generate_envelope(void)
- {
- char szRecipient[20];
- int nIndex = 0;
-
- // pComboTo is a pointer to a TComboBox
-
- // Selects first in list
-
- // This is the test that fails
- if(pComboTo->SetSelIndex(nIndex) < 0)
- {
- MessageBeep (-1);
- BWCCMessageBox (HWindow, "Enter names to send to!", NULL,
- MB_OK | MB_ICONSTOP);
- return;
- }
-
- do
- {
- pComboTo->GetText(szRecipient, 20);
- pComboTo->GetString (szRecipient, nIndex);
- // do something with text
- // Selects first in list
- nIndex++;
-
- if(pComboTo->SetSelIndex(nIndex) < 0)
- {
- // No more to send to
- break;
- }
-
- generate_recipients();
- }
- while (1);
- }
-
- What I'm trying to do, is first select item index 0, put the item into a
- string, use it, select next item, until SetSelIndex(nIndex) returns
- something less than 0 because there is no more items to be selected.
- For some reason, my first SetSelIndex(nIndex) fails for some unknown reason.
- I'm absolutely positive that there is something in the combobox.
-
- Thanks for any help!
-
-