Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox: How to detect the hihghlighted Item?
Message
From
25/12/2006 12:41:15
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01179918
Message ID:
01180122
Views:
20
>>>that means it's either in the valid or interactivechange - and not a true tooltip.
>
>HI Dragan,
>
>I've found a similar problem described in some delphi forum and an idea to solve it.
>
>The idea is: to start a timer every time the combobox gets focus or on MouseEnter and to disable it on lostfocus or when the mouse is neither in the combobox nor in the rectangle of the list.
>
>Then every e.g. 100 ms the timer checks the position of the cursor and calculates the index of the item that should be under the cursor.
>
>Quick and dirty:
>
>
>FUNCTION Timer
>	LOCAL loComboBox as ComboBox, lnMouseCOl, ;
>              lnComboTop, lnDistanceFromCombo, lnHighlitedIndex
>
>	lnHighlightedIndex = -1
>	loComboBox = This.oComboBox
>	
>	lnComboTop = loComboBox.Top
>	lnMouseCol = MROW(0,3)
>	
>	lnDistanceFromCombo = lnMouseCol - lnComboTop - loComboBox.Height
>	
>	If lnDistanceFromCombo < loComboBox.ListCount * This.nItemHeight
>             lnhighlightedIndex = Int(lnDistanceFromCombo / This.nItemHeight)
>        ENDIF
>
>        IF lnHighlightedIndex < 0
>    	     lnHighlightedIndex = .Null.
>        ENDIF
>
>    IF .not. ISNULL(lnHighlightedIndex)
>	    WAIT "Highlighted Item ist "+STR(lnHighlightedIndex) WINDOW nowait
>    EndIf
>
>    RETURN lnHighlitedIndex
>EndFunc    	
>
>
>Yes, it must be also proved, if the X-Position of the mouse ist still in the rectangle, but the biggest disappointment, that makes it all unusable is the fact, that the first item seen in the list is not the first item defined there. The list is always shown beginning with the item that has been last selected. And so the approach from above does not (and cannot!) take in account, that there are probably some more items, that are not visible and stand in the list virtually above the combobox. That's it...

And the user may have scrolled the list so even if you managed to calculate the offset from the current displayvalue, you still can't know whether it is the first displayed value or not.

It may be better to try with a simulated combo, ie. a textbox, downarrow command button, and an invisible listbox below it, which would come to life when needed. Then play with the listbox in a similar manner - or tame its automatic itemtips.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform