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
Solved

how can i call a URL

Posted on 2013-06-27
5
495 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 42

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

790 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