Article View: borland.public.cppbuilder.nativeapi
Article #9411Re: Problem with a sorted combobox
From: Zlika
Date: Sun, 11 Jul 2004 06:58
Date: Sun, 11 Jul 2004 06:58
45 lines
2450 bytes
2450 bytes
Thank you very much. It works now using CB_SETITEMDATA and CB_GETITEMDATA. "Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> a οΏ½crit dans le message de news:40f04255@newsgroups.borland.com... > > "Zlika" <zlika_eseSTOPSPAM@hotmail.com> wrote in message > news:40f03f38$1@newsgroups.borland.com... > > > I have a problem with the TComboBox component. > > I've got a sorted ComboBox. To know which item is selected (because the > > combobox is sorted), I first assign each item a ID through the Perform > > method: > > Why do you need an ID to know which item is selected? The ItemIndex > property already tells you exactly which item is selected. What exactly are > you trying to accomplish by assigning IDs manually? > > > ComboBox->Perform(LB_SETITEMDATA,pos,i); > > You are sending a ListBox message to a ComboBox. That will not work. You > should be using CB_SETITEMDATA instead of LB_SETITEMDATA. Or, just use the > Objects[] property instead and let the component handle the messages for you > internally: > > ComboBox->Items->Objects[pos] = reinterpret_cast<void*>(i); > > > number = ComboBox->Perform(LB_GETITEMDATA,ComboBox->ItemIndex,0); > > Likewise, use CB_GETITEMDATA instead of LB_GETITEMDATA. Or else use the > Objects[] property: > > number = > reinterpret_cast<int>(ComboBox->Items->Objects[ComboBox->ItemIndex]); > > > However, this last command always return 0! > > That is because you are using the wrong messages to begin with. > > > Gambit > >
Technical Details
Message-ID:
<40f0e512$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40f03f38$1@newsgroups.borland.com> <40f04255@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c046cfa35a952d0b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: "Zlika" <zlika_eseSTOPSPAM@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40f03f38$1@newsgroups.borland.com> <40f04255@newsgroups.borland.com> Subject: Re: Problem with a sorted combobox Date: Sun, 11 Jul 2004 08:58:29 +0200 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 82.120.6.135 Message-ID: <40f0e512$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089529106 82.120.6.135 (10 Jul 2004 23:58:26 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail