[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how can i call a URL

Posted on 2013-06-27
5
Medium Priority
?
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 43

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 30

Accepted Solution

by:
Olaf Doschke earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part III
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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