Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Google like incremental search in textbox
Message
From
15/10/2017 10:43:43
 
 
To
12/10/2017 23:16:20
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Miscellaneous
Thread ID:
01654954
Message ID:
01655012
Views:
76
you can use the vfp9 autocomplete textbox to make an interactive list of similar historical words when typing in textbox.
give to autocomplete the value 1.
a vfp table is created in home(7)+"autocomplete.dbf" and desserves the suggestions when you type in texbox.the suggestions begin with one word or (no word) and become big...

give a try to the code below (not perfect) using the original google search web page and intercepting the result in vfp.
*this code uses the original google textbox search to fire suggestions and retrieves result to a vfp textbo class.
*i guess its an autocomplete textbox but with a large google table to fill these suggestions.
*the google search  page is embed on a vfp olecontrol ("shell.explorer.2" oleclass) in a container.
*the ingenious beforenavigate2 method of the olecontrol redirect the url as vfp wants even in the vfp namespace.
*this is an exercice how to intercept the google textbox value after choice in autocomplete.

Publi yform
yform=Newobject("ytxtSearch")
yform.Show
Read Events
*
Define Class ytxtSearch As Form
	BorderStyle = 0
	Top = 106
	Left = 336
	Height = 144
	Width = 455
	ShowWindow = 2
	Caption = "Google search adaptation"
	MaxButton = .F.
	backcolor=rgb(112,108,110)
	Name = "Form1"

	Add Object text1 As TextBox With ;
		FontBold = .T., ;
		FontSize = 12, ;
		Anchor = 0, ;
		Height = 41, ;
		Left = 23, ;
		Top = 99, ;
		Width = 337, ;
		Name = "Text1"

	Add Object timer1 As Timer With ;
		Top = 106, ;
		Left = 360, ;
		Height = 23, ;
		Width = 23, ;
		Interval = 2000, ;
		Name = "Timer1"

	Add Object container1 As ycnt With ;
		Top = 0, ;
		Left = 0, ;
		Width = 456, ;
		Height = 90, ;
		Name = "Container1"

	Procedure Destroy
		Clea Events
	Endproc

	Procedure timer1.Timer
		Try
			Thisform.ycnt.olecontrol1.Document.body.Style.overflowx="hidden"  &&x scrollbar hidden, y scrollbar shown (hidden by container but can scroll with mouse)
			*hidding google buttons is to work...
			*thisform.ycnt.olecontrol1.document.getElementById("_eEe").style.visibility="hidden"
			*thisform.ycnt.olecontrol1.document.getElementById("_fZl").style.visibility="hidden"
			This.Enabled=.F.
		Catch
		Endtry
	Endproc

Enddefine
*-- EndDefine: ytxtSearch
*************************
Define Class ycnt As Container
	Top = 0
	Left = 0
	Width = 456
	Height = 90
	borderwidth=0
	backstyle=0
	Name = "ycnt"

	Add Object olecontrol1 As OleControl With ;
		oleClass="shell.explorer.2", ;
		Top = -300, ;
		Left = 1, ;
		Height = 450, ;
		Width = 500, ;
		Name = "Olecontrol1"

	Procedure olecontrol1.BeforeNavigate2
		*** Événement de contrôle ActiveX  ***
		Lparameters pdisp, url, Flags, targetframename, postdata, headers, Cancel
		Local m.x
		m.x=Strextract(Allt(url),"&q=","&oq")
		m.x=Strtran(m.x,"+"," ")
		Thisform.text1.Value=m.x
		Cancel=.T.
		This.Document.parentWindow.scrollBy(0,-This.Document.parentWindow.innerHeight)  &&can see also: parentwindow.scrollTo(coord-x,coord-y)
		Return .F.
	Endproc

	Procedure olecontrol1.Init
		This.silent=.T.
		This.Navigate("https://www.google.dz/?gws_rd=cr&dcr=0&ei=_iTjWcnhJonlUZuFrLAH")   &&google search url
	Endproc
Enddefine
*-- EndDefine: ycnt
************************
an illustration of the autocomplete textbox is in http://yousfi.over-blog.com/2015/01/a-simple-search-web-tool.html
or : http://yousfi.over-blog.com/2015/10/rss-feeds-reader-on-your-vfp-form.html
or: http://yousfi.over-blog.com/2015/08/google-searchers-with-a-simple-and-long-life-way.html
Previous
Reply
Map
View

Click here to load this message in the networking platform