Board index » cppbuilder » ComboBox->Items are longer as the ComboBox...How to show a hint that displays the full item...?

ComboBox->Items are longer as the ComboBox...How to show a hint that displays the full item...?

hi guys !

I have a problem with long items inside a combobox,
I would like to show a hint that show the full item inside the ComboBox...

I found a solution for the same problem with ListBox, look at the URL:

http://www.mers.com/cgi-bin/mer.exe/EXECSEARCH?pageno=1&searchtext=ki...
uptext=cppbuilder&linktype=viewmsg&msgno=19033&boardno=1820
But it doesn't work for a ComboBox, because...

[snip]

void __fastcall TForm1::AppShowHint(System::AnsiString &HintStr,bool
&CanShow, THintInfo &HintInfo)
{
   int listindex;

   if (HintInfo.HintControl == ListBox1)
   {
      listindex = ListBox1->ItemAtPos(HintInfo.CursorPos, true);  // .....A
ComboBox doesn't have this.....

      if(listindex != -1)
      {
         String itemtext = ListBox1->Items->Strings[listindex];

         if(ListBox1->Canvas->TextWidth(itemtext) > ListBox1->ClientWidth -
3)
         {
            TRect itemrect = ListBox1->ItemRect(listindex);
            TPoint TopLeft = Point(itemrect.Left, itemrect.Top);
            HintInfo.HintPos = ListBox1->ClientToScreen(TopLeft);
            HintStr = itemtext;
            HintInfo.ReshowTimeout = 250;
         }
      }
   }

Quote
}

Can someone tell me how I can convert the above code to show the Hint in the
ComboBox...?

Thanks ahead (especially to: Liz, Gambit/Remy, Asger and Hens...)

Oren

 

Re:ComboBox->Items are longer as the ComboBox...How to show a hint that displays the full item...?


Quote
Oren wrote:
> I have a problem with long items inside a combobox,
> I would like to show a hint that show the full item inside the
> ComboBox...
<snip>
> Can someone tell me how I can convert the above code to show the
> Hint in the ComboBox...?

Here's a hint, but I'm not doing it for you...
By subclassing the TComboBox window procedure and examining
the WM_CTLCOLORLISTBOX message, you can get the window
handle of the list box. The message is sent when the list box drops down.

Other Threads