Link to home
Start Free TrialLog in
Avatar of jgarth
jgarth

asked on

Help with CoolXP and using XpCombo box

I am evaluating if this OCX is a good idea to use in my project but already I have hit into a snag, The normal command Combo1.Listindex
used in VB to find the items index number does not seem to work with CoolXP.  Using xpCombo1.Listindex returns (-1) at all times.  Is there a way to get the Index number in a combo list using CoolXp Combo?
I have tried there web site but it's in German and even with google translation I found nothing useful.
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

What is there website ?
Avatar of GPrentice00
GPrentice00

An absolutely bare project, with just a form and default xpCombo  box, populated at runtime:  (Using the 2.7.71 version of the xpcombo; http://www.vb-fun.de/cgi-bin/loadframe.pl?ID=vb/komponenten/komponente0056.shtml)

Private Sub Form_Load()
    Me.xpCombo1.ItemsAddMulti 0, "red", "blue", "green", "yellow", "orange", "white"
    Debug.Print "nothing selected yet: "; Me.xpCombo1.ListIndex    
End Sub

Private Sub xpCombo1_Change()
    Debug.Print "Picked indexed item #: "; Me.xpCombo1.ListIndex;
    Debug.Print Me.xpCombo1.List(Me.xpCombo1.ListIndex)
End Sub

=====================================
Works exactly as it should - returns the correct index value when I click on "green"
nothing selected yet: -1
Picked indexed item #:  2 green


Under what context are you trying to examine a return and its failing?

Avatar of jgarth

ASKER

Yes works fine so long as its a dropdown type control otherwise it has big Bug in it.
Sorry to be Negative but I spent 8 hours coding around this Combo and now I get to a point and find it has a huge limitation ..... !!  Christ I am going to have to ditch tons of code just to remove and revert.

DO you know if there is any English Documentation on CoolXP?

Try this and you will see the problem

Private Sub Form_Load()
    Me.xpCombo1.Style = cEasyCombination
    Me.xpCombo1.Height = 1600
    Me.xpCombo1.ItemsAddMulti 0, "red", "blue", "green", "yellow", "orange", "white"
    Debug.Print "nothing selected yet: "; Me.xpCombo1.ListIndex    
End Sub

Private Sub xpCombo1_Change()
    Debug.Print "Picked indexed item #: "; Me.xpCombo1.ListIndex;
    Debug.Print Me.xpCombo1.List(Me.xpCombo1.ListIndex)
End Sub

Private Sub xpCombo1_Click()
   MsgBox "Picked indexed item #: " & Me.xpCombo1.ListIndex
End Sub




Nothing to apologize for at this point...

The only Eng documentation I've seen is that which gets installed with the CoolXP package, which has a toggle from German to English link.  Each control does provide a clickable link in its About box, but from there, they rapidly degrade into German forums...
My documentation infact only describes the combobox   .listindex  property as  a settable one, does not show a get-case sample as others do, although as we both know, it does function as it should for a listbox/combobox control in the default cDropdowncombo and cDropDownList modes.  Indeed, the EasyCombination mode has very little to work with (although setting  me.xpcombo1.listindex = 4 in some code somewhere will cause the textbox part to display 'orange' and select 'orange' from the list, thats of little help without the ability to detect the index, absolutely!)

That was after all the reason for the additional "under what context"

I have spent the better part of 90mins or so trying to adapt some API calls on comboboxes and listboxes to try to pull out something from the xpcombobox witout success, but suspect that that will be the solution path -- it will be necessary to identify the windows message for it first, and I don't have that tool reinstalled on my couple month old computer yet.  I've also tried some code to convert mouse-positions on a list into indices with no success either yet.

Documenation or not, there are not a lot of methods and properties with the control that even provide something to use in thix context, even though they do have some nice events that isolate it (my kingdom for  the listclick event to be listclick(index as integer)!!! ), but if you can use one of the two other styles which are more like the traditional comboboxes...

As stands, appears to be a bug with that mode perhaps, althought the documentation does seem to overlook the use of listindex as a return value in general.

Using WInspectorSpy it seems that the xpcombo in the ccEasyCombination mode has a listbox window child in it, so it should be possible using the right API calls to pull the index/value out of that.  Getting the right child window will be just a matter of a child-enum function.  I have been away all evening, and it grows late, but I will try for about an hour or so to make it work now, as its a personal challange.  If unable to do anything tonight, I will continue to chip away tomorrow night if that is not too late, or if you can understand what I mean about the child windows of the control and can go from there, power to you -- gotta go down a couple layers and get the right hwnd, but should be standard listbox-api calls from there.
ASKER CERTIFIED SOLUTION
Avatar of GPrentice00
GPrentice00

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or, use the listindex property in its Set mode to have the same result.  Probably better actually...

as in...

Public Sub ShowIndexed(ByRef xpc As xpCombo)
    Dim index As Integer
    Dim hwnd As Long
    hwnd = XPCIndexer.GetHwndOfXPComboLB(xpc)
    index = SelectedIndex(hwnd)

    xpc.ListIndex = index

End Sub

Avatar of jgarth

ASKER

GPrentice As the commercial says "Brilliant Just Brilliant"!

Increased points to 400 because this was just way more work than I ever imagined.
Thank you very much for all the time and Grey matter that you put in.

Oh BTW you might want to post this solution on there forum, I saw a post by someone in English asking the same question and the Someone posted back saying that it does not work with a regular VB Combo control so basicaly don't expect it to work with CoolXp Combo.  I realised the guy was full of crap because I use tons of VB Combo's in this mode and the index works perfectly.

Thanks Again.
You are very welcome, and I am glad that I contributed to your not having to undo piles of code.
Thanks for the points, esp for boosting them.
I will consider your suggestion, maybe take some time to clean it up more first if possible, but definitely if someone said it can't be done, thats reason enough to show a solution.