Solved

how can i call a URL

Posted on 2013-06-27
5
439 Views
Last Modified: 2013-07-17
I want to put a button in a form that call a URL  (ex www.google.com"
How can i do that?
thank you very much
Lucília Coelho
0
Comment
Question by:luciliacoelho
5 Comments
 
LVL 7

Expert Comment

by:dec0mpile
ID: 39282487
Try to do this:

declare integer ShellExecute in shell32.dll ;

ShellExecute(0,"open","www.google.com",0,0,1)

Open in new window

Also see this example:
http://www.berezniker.com/content/pages/visual-foxpro/opening-url-default-web-browser
0
 

Author Comment

by:luciliacoelho
ID: 39282904
i try the example and it works well, but the the result is 3 browsers open. the code off the example is as follow

#DEFINE SW_SHOWNORMAL 1
 
lcUrl = "http://msdn.microsoft.com/vfoxpro"

* WSH
oShell = Createobject("wscript.shell")
oShell.Run(lcUrl)
*oShell.Run(lcUrl, SW_SHOWNORMAL)

* ShellExecute Win API
DECLARE Long ShellExecute IN "Shell32.dll" ;
      Long hwnd, String lpVerb, String lpFile, ;
      String lpParameters, String lpDirectory, Long nShowCmd
ShellExecute(0, "Open", lcUrl, "", "", SW_SHOWNORMAL)

* Shell object
oShell = CREATEOBJECT("Shell.Application")
oShell.Open(lcUrl)
 

What is wrong in this code?
Kind regards
LC
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39282991
Everything is OK.

Sergey Berezniker published THREE different examples how to open web browser and display the web page... and you've executed all of them so the result is THREE browsers open...

You should select one method only.

You may also define the search term when invoking Google. To search for, e.g. My first Googling attempt  define the following URL:

lcUrl = "http://www.google.com/#q=My+first+Googling+attempt"


More advanced use of web browser is OLE automation where you can control almost everything programmatically from FoxPro or other language. See the following exsample: http://fox.wikis.com/wc.dll?Wiki~IEAutomationExample
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 39283510
Do you really want a browser to open?

You can also put a Webbrowser Control on your form by adding an OLECONTROL to it from the form controls toolbar and choosing "Microsoft Web Browser" from the Insert Object dialog.

Then in your form button do
thisform.olecontrol1.navigate2("www.google.com")

VFP also offers the hyperlink control, which again opens a browser:
o = CreateObject("hyperlink")
o.NavigateTo("www.google.com")

Open in new window


And to complete the overview about possibilities you can also do a silent http request via

loRequest = Createobject('MsXml2.XmlHttp')
loRequest.Open("GET","http://www.google.com", .F.)
lcResponse = loRequest.ResponseText

Open in new window

This gives you the pure html code, no secondary requests are done, as a browser does, eg the google logo isn't loaded. The MsXml2.XmlHttp also offers an ResponseXML property and XML parsing options.

And last not least you can use
DECLARE INTEGER URLDownloadToFile IN urlmon.dll;
    INTEGER pCaller,;
    STRING  szURL,;
    STRING  szFileName,;
    INTEGER dwReserved,;
    INTEGER lpfnCB

nResult = URLDownloadToFile(0, "http://www.google.com", "D:\temp\google.html", 0,0)

Open in new window

...which returns the html of google.com into a html file. You can also request other things but the start page, you can eg download files like jpg, zip, etc, knowing their URL.

Bye, Olaf.
0
 

Author Comment

by:luciliacoelho
ID: 39332768
I've requested that this question be closed as follows:

Accepted answer: 0 points for luciliacoelho's comment #a39282904

for the following reason:

Ir worked as sent in the expert answer
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now