? on combo box autocompletion

Started by Paul D. Elliott, July 12, 2004, 03:24:40 PM

Previous topic - Next topic

Paul D. Elliott

Okay, I had missed that line. But had to change it to <> instead of >
to get previoous matches.  some of my lists have similar entries.
Wouldn't this have to be another static variable per combo box?

Thanks.  Now on to other things ( as soon as the changing of TABS can
be made under program control ).

Roger Garstang

Yes it is a STATIC variable.  It is all in the code.  And, you will have it all in the CBN_EDITCHANGE function of each combo, so they will all have their own STATIC variables, etc.  You wouldn't want this in say a CUSTOM function of your main form that handles for all combos as they will all be different lengths.  <> works, but I had it the other way cause usually when I hit backspace I expect it to cancel out whatever it is doing, like in PB when it changes the case for keywords...backspace puts it back and leaves it the way it was...or in IE when you keep hitting backspace in the URL box it keeps the list fresh, but doesn't autocomplete again until you type a new character.

Anonymous

I just wonder about the status of this, does the subclass code still need to be included?

It seem to work ok, so far, but haven't tested it that much yet. I'm also trying to extend it a bit to actually do something as well in response to the changed selection.

How can I catch that the user hit Enter (or Tab) to "select" the displayed value for use and "move on"?

/Joakim

Roger Garstang

Good question, I didn't see anything about it in the last update...I'm kinda curious about the other button styles too that aren't AUTO that I mentioned, so toggle buttons would be easier.

As for the extending question, Tab already selects and moves on, Enter would just be another character to process in the subclassed procedure where the tab is...and to make it a little more reusable, you might change it to sending Tab to the parent of the edit control which would be the combo instead of the hard coded handle...and perhaps send the Enter key to the parent of the parent (Combos parent or the Form/Window containing it)...that way it could handle Enter as being the default button push or something.

As for doing something on changing selection, you'd do that in the normal SelChange event for the combo.

Anonymous

Quote from: Roger GarstangAs for the extending question, Tab already selects and moves on, Enter would just be another character to process in the subclassed procedure where the tab is...and to make it a little more reusable, you might change it to sending Tab to the parent of the edit control which would be the combo instead of the hard coded handle...and perhaps send the Enter key to the parent of the parent (Combos parent or the Form/Window containing it)...that way it could handle Enter as being the default button push or something.

Hmm not sure I understood that really, I'm pretty new to PB and FF programing, have had the VB desease for many years... :-)

Quote from: Roger Garstang
As for doing something on changing selection, you'd do that in the normal SelChange event for the combo.
Yes, I understand that but here I'm a bit spoiled by VB, setting the selection in code in VB usually triggers a click event or something to react to, but setting the selection in code with FF (at least with FF_COMBOBOX_SETCURSEL) doesn't seem to trigger code in FUNCTION FORM1_COMBO1_CBN_SELCHANGE or _SELENDOK, only seem to happen when a selection is done in the control, or am I missing something here?

The modification I have done to your original code is this

LOCAL  MyData,searchResult AS LONG
Local lengthComboString As Dword
Local comboString As String
Static previousSize As Dword
Static preventLoop As Dword

If preventLoop = 0 Then
   preventLoop = 1
   comboString= FF_CONTROL_GETTEXT(hWndControl)

   lengthComboString = Len(comboString)
   If lengthComboString > previousSize Then
       searchResult= SENDMESSAGE(hWndControl, %CB_SELECTSTRING, -1, STRPTR(comboString))
       IF searchResult = %CB_ERR THEN
        FF_CONTROL_SETTEXT(hWndControl, comboString)
       ELSE
   MyData = FF_COMBOBOX_GETITEMDATA (HWND_FRMATLASVIEW_CBOCOUNTRY, searchResult  )
   FillListbox FORMAT$(MyData , "000")
       
       END IF
   End If
   SENDMESSAGE(hWndControl, %CB_SETEDITSEL, 0, MAKDWD(lengthComboString,-1))
   previousSize = lengthComboString
   preventLoop = 0
End If  


I simply pull a stored data Item from the combo and send it to a sub that will fill a list box based on it. That seem to work fine, but when user hits Enter in the combo edit portion I want it to make focus jump to the list box, just that. I'm sure it's an easy one, I just haven't found it yet ;-)

I haven't used the subclassing part btw, and it seem to work fine so far...

/Joakim

Roger Garstang

Just posted a reply over at PB that made me look for my old code here.  It made me wonder if this was added to the new FF.  And, my other code for allowing coloring of Combos:

(I had it documented as below, but seem to remember it not working with the combo with the list always visible or something, so it may need tweaked)


Case %WM_CTLCOLOREDIT, %WM_CTLCOLORLISTBOX, %WM_CTLCOLORSTATIC, %WM_CTLCOLORBTN
         'Message received from child control about to display.
         'Set the Color properties here.
         'lParam is the handle of the Control. wParam is the hDC.
         FF_hDC = wParam

         ff_control = GetProp(lParam, "FF_PTR")
         If ff_control = 0 Then
            ff_control = GetProp(GetFocus(), "FF_PTR")
            If ff_control = 0 Then Exit Select  'let the DefWindowProc handle the coloring
         End If

Roger Garstang

Found a function I didn't know about in another thread that may help this too: GetComboBoxInfo

Elias Montoya

#22
 I cant get it to work, and my english is being forced at max. Is it working? Am i missing something? Are we waiting for a change in Firefly?

I need to add an autocomplete combobox, but when i subclass the combobox i cant get WM_CHAR nor WM_KEYDOWN to work. :(

Added:
Silly mistake, it works now. :),  i just have the problem with TAB not working. my subclassing didnt work either... whats the status on this?