A very basic google translate embed on a form

Published on by Yousfi Benameur


*this code set google translate page on a vfp form just as needed area
*i use it to translate my texts to other languages and its very useful.

*copy-paste make detection auto an check the goal lang to translate.
*As an utility build a proj, add a config.fpw and raise an exe you can put on desktop

*or in taskbar.
*obviously,Internet must be connected.

*A config.fpw could be as follow.
           *!*     screen=off
           *!*     resource=off

 

*Begin code
If !_vfp.StartMode=0
On Shutdown Quit
Endi
ycheck=yinternet()
If ycheck=.F.
Quit
Endi

*form
Publi ygt
ygt=Newobject("ygoogle_translate")
ygt.Show
Read Events


Define Class ygoogle_translate As Form
BorderStyle = 2
Height = 371
Width = 895
ShowWindow = 2
DoCreate = .T.
AutoCenter = .T.
Caption = "yGoogle translate"
Name = "Form1"

Add Object olecontrol1 As OleControl With ;
oleclass="shell.explorer.2",;
Top = -111, ;
Left = -12, ;
Height = 564, ;
Width = 912, ;
Anchor = 15, ;
Name = "Olecontrol1"

Procedure Init
With Thisform.olecontrol1
.silent=.T.
.Navigate("https://translate.google.com/")
Endwith
Endproc

Procedure Destroy
Clea Events
Endproc

Enddefine

Function yinternet()
Declare Integer InternetCheckConnection In wininet;
STRING lpszUrl, Integer dwFlags, Integer dwReserved

#Define FLAG_ICC_FORCE_CONNECTION 1
lcURL="http://www.microsoft.com"
lResult = (InternetCheckConnection(lcURL, FLAG_ICC_FORCE_CONNECTION, 0)=1)
If lResult=.T.
Return .T.
Else
Messagebox("There is no internet connexion ! this must be established mandatory to run the program.",0+16,"internet Connection")
Return .F.
Endi
Endfunc

*end code

 

A very basic google translate embed on a form
To be informed of the latest articles, subscribe:
Comment on this post