Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Howard Hendler
  Where is Howard Hendler?
 New City
 New York - United States
 Howard Hendler
 To: Mike Gagnon
  Where is Mike Gagnon?
 Pointe Claire
 Canada
 Mike Gagnon
 Tags
Subject: RE: Autocomplete file/directory chooser?
Thread ID: 112271 Message ID: 112370 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Tuesday, November 07, 2006 8:45:48 PM         
   


>>Aren't just talking about
Ah that word 'just'; its never 'just (something)' :-)

Thanks for the continued input.

The code below works, somewhat. The initial ADIR function
needs "c:\*.*" as the 2nd arg. Also, there is no recursion, so "\"
has to be trapped, ADIR() re-run and the control refreshed as the
typed path gets deeper. I've done this with something like....

IF lnlastkey == 92
trimval = TRIM(this.DisplayValue)
=ADIR(mydrive, trimval + "*.*", "D")
this.Refresh()
this.displayValue = trimval
ENDIF

Actually with this, the initial call to ADIR can be eliminated.

But this too only "sort-of" works, but since the mydrive array does not
contain the full path from the beginning, only the contents of the
currently displayed directory, there's no opportunity for a true
autocomplete, unless, each time you re-run ADIR, you also prepend
the full path to each element. Also, the cursor jumps back to the
beginning upon refresh (manageable).

At this point the cost/benefit does not justify the extra work for
me to get it as tight as I would want, and it would never look and feel
exactly like the Windows examples I've mentioned.

BTW, I see in VB 2005, there is an autoCompleteSource property for
combo boxes that you simply set to "FileSystem" and it does exactly
("just") what I'm looking for. Can I use VB controls in VFP?


Thanks again,
-hh



> Aren't just talking about
use ADIR() on your c:\ fill a combo with the result and use incrementalsearch in the combo? Or do you need it autofill? If so take a look at this.
>
Public Array mydrive[1]
> Adir(mydrive,"","D")
> _Screen.AddObject("oCB","ImprovedComboBox")
> _Screen.oCB.Left = 10
> _Screen.oCB.Top = 10
> _Screen.oCB.Width = 200
> _Screen.oCB.RowSource = "mydrive" && Alias Name
> _Screen.oCB.RowSourceType = 5 &&Alias
> _Screen.oCB.Visible = .T.
> *_screen.RemoveObject("oCB") && this code in command window removes the combobox
> 
> Define Class "ImprovedComboBox" As ComboBox
> 	acstyle = 2
> 	lastdisplayvalue = ""
> 	lastsellenght = 0
> 	lastselstart = 0
> 	sellenght=0
> 	Style = 0
> 
> 	Procedure InteractiveChange
> 	Local lnStyle, lnLastKey, lcDisplayValue
> 
> 	lnLastKey=Lastkey()
> 	lnStyle = This.Style
> 	If This.Style = 2
> 		This.Style = 0
> 	Endi
> 	If (lnLastKey>=32 And lnLastKey<=126)
> 		If This.SelStart>=1
> 			lcDisplayValue=Substr(This.DisplayValue,1,This.SelStart-1)+(Chr(lnLastKey))
> 		Else
> 			lcDisplayValue=(Chr(lnLastKey))+Allt(This.DisplayValue)
> 		Endi
> 		If Empty(lcDisplayValue)
> 			lcDisplayValue=Allt(Chr(lnLastKey))
> 		Endi
> 		For i = 1 To This.ListCount
> 			If Upper(lcDisplayValue) == Upper(Substr(This.List(i),1,Len(lcDisplayValue)))
> 				This.DisplayValue=This.List(i)
> 				This.SelStart=Len(lcDisplayValue)
> 				nlLength=Len(Allt(This.DisplayValue))-Len(lcDisplayValue)
> 				This.SelLength=Iif(nlLength <0,0,nlLength)
> 				This.lastdisplayvalue = This.DisplayValue
> 				This.lastselstart = This.SelStart
> 				This.lastsellenght = This.sellenght
> 				Return
> 			Endi
> 		Endfor
> 	Endif
> 	Endproc
> Enddefine
> 

>
>
> > Ken,
> >
> > Thanks for your input. I am aware of this. I am looking to replicate the feature in a combo box, without the dialogue, as implemented in IE's File/Open, the Explorer address bar or the Update Driver window. In general it seems that this control or functionality exists somewhere in the bowels of one Windows API or another; whether or not I can get to it from VFP, is the real question.
> >
> > -hh
> >
> > > > >>What exactly do you mean by "simplify?"
> > > >
> > > > Go File/Open in IE. Type c:\docu and stop. You can now hit [tab] and have 'ments and settings' filled in for you, and so on. That's what I mean.
> > > >
> > > > This type of control shows up elsewhere in Windows (it's in the 'update driver' dialogue in device manager). If I can't get to it, not a huge deal, but it would be a handy addition/alternative to the GETFILE dialogue for those who use the keyboard.
> > > >
> > > > Thanks,
> > > > -hh
> > > >

> > >
> > > Howard,
> > >
> > > Take a look at this image - you have the same thing in GETFILE().
> > >
> > >
> > >
> > > Type in "C:\Doc" and downarrow to "c:\Documents and Settings" add a "\" and down arrow to the user name you want ...
> > >
> > > Ken
> > > You shall know the truth - and the truth shall set you free. (John 8:33)

>
>
>
> Mike Gagnon
>


ENTIRE THREAD

Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 12:26:57 AM
RE: Autocomplete file/directory chooser? Posted by Mike Gagnon @ 11/7/2006 1:00:00 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 1:10:47 AM
RE: Autocomplete file/directory chooser? Posted by Ken Murphy @ 11/7/2006 1:16:49 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 1:39:27 AM
RE: Autocomplete file/directory chooser? Posted by Ken Murphy @ 11/7/2006 1:58:51 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 3:20:14 AM
RE: Autocomplete file/directory chooser? Posted by Mike Gagnon @ 11/7/2006 4:08:36 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 8:45:48 PM
RE: Autocomplete file/directory chooser? Posted by dencio @ 11/7/2006 8:58:59 AM
RE: Autocomplete file/directory chooser? Posted by Mike Gagnon @ 11/7/2006 11:28:14 AM
RE: Autocomplete file/directory chooser? Posted by tushar @ 11/7/2006 3:57:05 PM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/7/2006 10:35:54 PM
RE: Autocomplete file/directory chooser? Posted by Ken Murphy @ 11/8/2006 2:16:48 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/8/2006 5:27:58 AM
RE: Autocomplete file/directory chooser? Posted by tushar @ 11/8/2006 4:36:26 PM
RE: Autocomplete file/directory chooser? Posted by dencio @ 11/9/2006 9:40:55 AM
RE: Autocomplete file/directory chooser? Posted by Howard Hendler @ 11/14/2006 1:53:36 PM