Board index » cppbuilder » Re: with a TComboBox can I ....

Re: with a TComboBox can I ....


2003-11-14 08:49:54 PM
cppbuilder17
Giovanni Resta < XXXX@XXXXX.COM >wrote:
Quote
It would be nice if, while the user has clicked on the
combobox (causing the appereance of the drop list) and he is
moving on the list of items with the pointer, a text is
displayed somewhere, explaining the meaning of that item (even
better, a floating window with the explanation appear just
below or near the pointer...)
Use Style csOwnerDrawFixed and OnDrawItem. Check the State.
If it is selected and the list is dropped down, react. Here is
a simple example:
void __fastcall TFormMain::ComboBox1DrawItem(TWinControl *Control,
int Index, TRect &Rect, TOwnerDrawState State)
{
ComboBox1->Canvas->FillRect(Rect);
ComboBox1->Canvas->TextOut(Rect.left, Rect.top, ComboBox1->Items->Strings[Index]);
if(State.Contains(odSelected) && ComboBox1->DroppedDown)
Label1->Caption = String("You are chosing: ") + ComboBox1->Items->Strings[Index];
else
Label1->Caption = "";
}
To display a hint, use THintWindow. Here is a thread were the
whole issue is explained:
makeashorterlink.com/?P46652A86
 
 

Re:Re: with a TComboBox can I ....

Let me explain what I would like to obtain, (I'm a little
pessimistic...)
I have a TComboBox one line high, read-only.
(in practice the user must select one of the items from the list,
clicking on it to reveal its contents).
It would be nice if, while the user has clicked on the combobox (
causing the appereance of the drop list) and he is moving on the list
of items with the pointer, a text is displayed somewhere, explaining the
meaning of that item (even better, a floating window with
the explanation appear just below or near the pointer...)
thanks,
g.
 

Re:Re: with a TComboBox can I ....

You can use a TTimer event and check the ComboBox->ItemIndex value
with it's old value
int oldComboBoxIndex = ComboBox->ItemIndex;
void __fastcall TForm::Timer1Timer(TObject *Sender)
{
Timer1->Enabled = false;
if (oldComboBoxIndex != LayerComboBox->ItemIndex)
{
oldComboBoxIndex = ComboBox->ItemIndex;
myDisplayHint(oldComboBoxIndex);
}
Timer1->Enabled = true;
}
Ciao
 

{smallsort}

Re:Re: with a TComboBox can I ....

Thorsten Kettner wrote:
Thanks to all, I'll check.
g.