Board index » cppbuilder » Selected ComboBox

Selected ComboBox


2005-11-10 11:16:58 PM
cppbuilder86
How can I programmatically determine whether a given combo box is currently
selected on the screen. Apparently Focused() does not apply.
 
 

Re:Selected ComboBox

Quote
How can I programmatically determine whether a given combo box
is currently
selected on the screen. Apparently Focused() does not apply.
It works with me (BCB5). How are you checking it? Which other
components are on the form?
Steve.
 

Re:Selected ComboBox

Thanks, Steve, for replying.
I check the TComboBox by checking :
if (CategoryBox->Focused())...
There are an abundance of other components on the form: other TComboBoxes,
ListBoxes, Edit fields, GroupBoxes, etc. However, only the Category
ComboBox is evidently selected, as the item showing in the ComboBox is
hichlighted in blue and no other component is highlighted.
Caryl
"Steve Aletto" < XXXX@XXXXX.COM >wrote in message
Quote
>How can I programmatically determine whether a given combo box
>is currently
>selected on the screen. Apparently Focused() does not apply.

It works with me (BCB5). How are you checking it? Which other
components are on the form?

Steve.


 

{smallsort}

Re:Selected ComboBox

I should also note that there is a PopupMenu associated with the Combobox
that is activated when the right mouse button is pressed. It is in response
to that PopupMenu that I check the focus of the ComboBox. Might the
PopupMenu have stolen the focus? The ComboBox is, however, still
highlighted.
Caryl
"Steve Aletto" < XXXX@XXXXX.COM >wrote in message
Quote
>How can I programmatically determine whether a given combo box
>is currently
>selected on the screen. Apparently Focused() does not apply.

It works with me (BCB5). How are you checking it? Which other
components are on the form?

Steve.


 

Re:Selected ComboBox

Quote
I should also note that there is a PopupMenu associated with
the Combobox
Tried also that situation, it still works. What's the Style of
the ComboBox? It should be csDropDown, otherwise that can be the
reason.
If it's not, then you could check the focus in the following
way:
if (FormX->ActiveControl == ComboBoxX)
...
because the Focused property indicates the input focus, not the
control focus.
HTH,
Steve.
BTW: wrong group.
 

Re:Selected ComboBox

Thanks again, Steve.
The Style was csDropDownList so that might have been the problem.
In any event, I resolved the problem by using OnContextPopup for each of the
ComboBoxes on the form rather than trying to use a common PopupMenu for all
of them and distinguish between them by checking for Focused. It is not as
clean, but it seems to work.
I appreciate your help.
Caryl
"Steve Aletto" < XXXX@XXXXX.COM >wrote in message
Quote
>I should also note that there is a PopupMenu associated with
>the Combobox

Tried also that situation, it still works. What's the Style of
the ComboBox? It should be csDropDown, otherwise that can be the
reason.

If it's not, then you could check the focus in the following
way:

if (FormX->ActiveControl == ComboBoxX)
...

because the Focused property indicates the input focus, not the
control focus.

HTH,

Steve.

BTW: wrong group.


 

Re:Selected ComboBox

Quote
trying to use a common PopupMenu for all
of them and distinguish between them by checking for Focused.
It is not as
clean, but it seems to work.
Well, have a look at the TPopupMenu's PopupComponent property
then!
"Read PopupComponent to determine which control is currently
using the popup menu. In applications where multiple controls
share the same pop-up menu, use PopupComponent to determine
which of them displayed the menu."
Steve.
 

Re:Selected ComboBox

Wow! That looks like exactly what I wanted!
Thanks again.
Caryl
"Steve Aletto" < XXXX@XXXXX.COM >wrote in message
Quote
>trying to use a common PopupMenu for all
>of them and distinguish between them by checking for Focused.
>It is not as
>clean, but it seems to work.

Well, have a look at the TPopupMenu's PopupComponent property
then!

"Read PopupComponent to determine which control is currently
using the popup menu. In applications where multiple controls
share the same pop-up menu, use PopupComponent to determine
which of them displayed the menu."

Steve.