Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box restictions...

Status
Not open for further replies.

markSaunders

Programmer
Jun 23, 2000
196
GB
Scenario:
the mandatory field is presented to the user in the form of a standard combo box (type 2)

consistency and common sense dictate that the column of options (presented in combos) should be of the same width. All other options are Yes/No bar on or two of these madatory fields that happen to be around 15 / 20 characters in length

Problem:
enabling the user to view the full text of the option without having to a)scroll along the width of the combo or b)having to extend the width of 2 or 3 combos to accomodate the full text - thus making these combos look ridiculously large.

Tried:
enlarging the combo on GotFocus to the width of the largest text string contained in its list but the problem here is that when the .width is changed, the user is not presented with the list underneath the box, this requires a firther click.
swapping between the combo and then making a list visible over the top. the user clicks on the list (with a wider width), the value is transferred to the original (shorter) combo and the user thinks its all one object - the problem with this is (maybe due to my inferior programming?) is that the code is messy and would have to cover many events. also the fact that the everywhere its needed the developer needs 2 objects (and possiblyu populate both with the same data?)

Plea:
any ideas.....


[sig]<p> Mark Saunders<br><a href=mailto: > </a><br><a href= Solutions</a><br> [/sig]
 
Mark,
The problem here is that the combobox does not generate a mousemove event, so unless you want to deal with subclassing the combobox, I'd suggest changing to a list box. Then you can use the WindowsAPI to get the location of the mouse, and use that to find out which item the mouse is over, then just set the tooltip property to be the text that's in the list box at that position.

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function GetCursorPos Lib &quot;user32&quot; (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib &quot;user32&quot; (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SendMessage Lib &quot;user32&quot; Alias &quot;SendMessageA&quot; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Const LB_ITEMFROMPOINT = &H1A9


Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim tPOINT As POINTAPI
Dim iIndex As Long
Call GetCursorPos(tPOINT)
Call ScreenToClient(List1.hWnd, tPOINT)
iIndex = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.X And &HFF) Or (&H10000 * (tPOINT.Y And &HFF))))
If iIndex >= 0 Then
'Extract the List Index
iIndex = iIndex And &HFF
'set the Lists ToolTipText
List1.ToolTipText = List1.List(iIndex)
End If
End Sub

You can simulate a combo box with a text box and list box.

[sig]<p>nick bulka<br><a href=mailto: > </a><br><a href= </a><br>Get your technical books at Bulka's Books<br>
[/sig]
 
cheers nik.
with a little onGotFocus and onLostFocus fiddling i can have a text box perform pretty much as a combo control but with an elongated (or as per your code) text-tip'd list box.

the only problem here is that the form now contains the maximum number of controls - i presume if i wrap this up as an ActiveX control then each instance of the control will =1 (as opposed to 2 or 3 seperate control)....

...now to ActiveX it....:^)

thanx for your help
Mark Saunders
 
i found that users expected the control to act exactly as a combo control... more so as this is the most frequently used component on the flag setting screens i'm currently doing.

i did stumble along some code that, with the use of a function and API call allows me to set the [tt].list[/tt] width of the standard vbCombo - this works but the real problem comes when (as you indicate above i think in reference to sub-classing) i decided to add the [tt].widthList[/tt] property (and also a [tt]yesNoBox[/tt] boolean property) that the developer can set - see thread708-30461 [sig]<p> Mark Saunders
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top