Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a timer-object and a hyperlink-object - could that lead to a dia-show? 2

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
When a Hyperlink-Object (eg. Hyperlink1) is initiated, the following example of a click-event of (name = cmdbutton1) would run:

*Timer-Object Init:
cmdbutton1.click()
cmdbutton2.click()

*Click-event for cmdbutton1:

x = "Alvaro Castagnet"
STORE ALLTRIM(x) TO nn
y = "https:"+"//ww"+"w.google"+".de/search?q="+nn+"&biw=1920&bih=1013&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjOyImsm7vMAhXFzxQKHf4mBrgQ_AUIBigB#tbm=isch&q="+nn+"+Aquarell"
thisform.hyperlink1.NavigateTo(y)

That runs well, but now the next approach is this command:


*Click-event for cmdbutton2:

x = "Joseph Zbukvic"
STORE ALLTRIM(x) TO nn
y = "https:"+"//ww"+"w.google"+".de/search?q="+nn+"&biw=1920&bih=1013&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjOyImsm7vMAhXFzxQKHf4mBrgQ_AUIBigB#tbm=isch&q="+nn+"+Aquarell"
thisform.hyperlink1.NavigateTo(y)

When the timer is initiated then the click-event of cmdbutton1 is executed. But then I have to close the homepage - manually by clicking on it - to get the second homepage of Joseph Zbukvic
Has anyone an idea, whether this could be done without closing the 1st homepage manually, but let's do it the timer after a certain time? (That would lead to a dia-show in this example...)

The general question behind is for perhaps, whether keypushes in the Internet environment could be controled from/via VFP9

May this is a stupid question....
Klaus


Peace worldwide - it starts here...
 
Klaus,

There's a much easier way of doing this, which would also solve your specific problem.

Instead of using the hyperlink class, use the ActiveX Web Browser control. This is one of the controls that come with VFP.

In summary, you would drop the control on your form. In the Click events of your buttons, you would put code to call the control's Navigate2 method, passing the URL of the page that you wish to display (the same URL that you are at present passing to hyperlink1.NavigateTo). Clicking the first button would cause the first page to be displayed. Clicking second button would display the second page - in place of the first one. So no need to manually close it.

Going one step further, if you place the Web Browser control on a form by itself, you can programatically control the form (for example, by calling its Release method), just like any other form.

If you want both pages to be displayed at the same time, you could place two instances of the control on one form. Or have two separate forms. Or place them on different pages of a pageframe.

I've simplified the above description slightly, but I hope I've given you enough to start thinking about.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
@Mike - again I would like to thank you very much. I had no experience with ActiveX controls or classes/subclasses when I was on duty more than 13 years ago. (That should have saved me a lot of time, but I had not the time to find out all the huge features which are included in VFP due to heavy workload and of course English is not my first language.) But now I have time to think and go deeper - and it makes very happy to see the amazing power and capability of VFP although I still have to learn a lot more. (I still regret that MS stopped the support for VFP in early 2000). So the first step you gave me was understood by me and your hint makes it working - but then you wrote:
if you place the Web Browser control on a form by itself - what does that mean (by itself)?

Nice weekend
Klaus

By the way:
I never had been in a better forum like this one. The answers are so quick and excellent - that's what I learned already in 2003 - but nothing has changed up to now - and I would like to thank all people here, who helped me at that time and help me now. That was a must for me to write this.

Peace worldwide - it starts here...
 
if you place the Web Browser control on a form by itself - what does that mean (by itself)?

What I had in mind was that the Web Browser control would be on a different form than the one containing the two command buttons. That way, you could close the browser form without affecting the command button form.

But let's take that a bit further. Create a form, place a Web Browser control on it, and make it so that the browser fills the form. Then, in a command button (or other control) on your main form, write code to open the browser form, and have it navigate to a desired URL. You have just created your own mini VFP-based web browser over which you have full programmatic control.

The browser is actually an instance of Internet Explorer. You can make it do anything that Internet Explorer can do. You could add Forward and Back buttons to the form; add a textbox into which the user can type a URL; and so on.

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
@Mike: That sounds good, because to have the web-browser separated from the command-or menucenter would save place on the form for the menu.
Meanwhile I found out, that in some cases it would be fine to have also a further detail for an item available and that is the COLOR.
Example for this cascade: FLOWERS ROSES YELLOW would lead me to yellow roses only in Google an gives an expression how are painted in watercolor by others, wenn you also add "watercolor" to your search.
You can easily test it with this link:
that works for the all painting techniques (oil, watercolor, acrylic) where color was selected - for drawings with pencil or coal of course only black or white (they are no colors) would lead to a good result.
I think that could be done with a pageframe with colored tabs on the form, as colors on tabs can be identified faster then labels.

Tomorrow we will be on vacation (baltic sea) for 14 days, but I will keep you informed as there is internet-connection available - and I am glad to know, that in case of trouble I can rely to find friendly support by you and others here.


*NB At the moment I look for an easy way to transfer good links (e.g. homepages of painters) found by me in the web into my VFP-table (other than manually drag and drop...better would be a tool which captures and imports it into my table. When found I will report it here.

Regards
Klaus






Peace worldwide - it starts here...
 
To transfer a link from Web into a *.dbf-file I use at the moment this code:

*Testclip.prg /Testclip.exe


CLOSE data
*This program fills an empty record with the contents of the selected Internet-link (copied into the clipboard)


USE myfile
*File has a field "link" C(70)

APPEND BLANK
REPLACE link WITH _cliptext

*This program was compiled to an exe-file and after having found an interesting internet-link I mark it and copy it by using Strg-C and after this I click this exe.

Perhaps there is a better method?


Peace worldwide - it starts here...
 
If you browse using the Webbrowser Control you could simply know the URLs you surf by reading olecontrol1.document.location.href
And to get to URLs you could read favorites as "bulk load" and then pick urls of interest.

IE Favorites for example are stored in a url file each in ADDBS(GETEENV("USERPROFILE"))+"Favorites\"
A URL file contains some text and one line of it is URL=...
You can use ALINES() or STREXTRACT() to get at that value.

For example:
Code:
LOCAL lcFavoritesLocation, lnURLFile, lcURLFile, lcURL
LOCAL ARRAY laFavorites[1]

lcFavoriteLocation = ADDBS(GETENV("USERPROFILE"))+"Favorites\"
FOR lnURLFile = 1 TO ADIR(laFavorites,lcFavoriteLocation+"*.url","",1)
   lcURLFile = FILETOSTR(lcFavoriteLocation+laFavorites[lnURLFile,1])
   lcURL = STREXTRACT(lcURLFile,"URL=",CHR(13)+CHR(10),1,3)
   ? JUSTSTEM(laFavorites[lnURLFile,1]), lcURL
ENDFOR


Bye, Olaf.
 
At the moment I look for an easy way to transfer good links (e.g. homepages of painters) found by me in the web into my VFP-table

Here's a possible solution:

1. Create a form, and place a Web Browser control on it, as per my post above. Name the Web Browser caontrol, say, oleBrowser.

2. Add a textbox to the form. This will be used to enter URLs. In the LostFocus of the textbox, write code to navigate to the URL. You could also add two command buttons, to be used as Back and Forward buttons respectively.

3. Add a command button to "save" the current page in your DBF. You will click this button whenever you reach a page that you want to save.

4. Create a table (DBF), with at least two character fields, named, say, cURL and cTitle.

5. In the click event of your "save" button, add this code:

Code:
APPEND BLANK
REPLACE cURL WITH THISFORM.oleBrowser.Document.Location.HRef, ;
 cTitle WITH THISFORM.oleBrowser.Document.Title

6. Run the form. Use the textbox to navigate to the sites of interest. Follow hyperlinks, etc. in the usual way. When you find a page that you want to save, click the "save" button.

Obviously, you could go much further with this idea. You might click on individual images to save their URLs, or perhaps even to save a copy of the image and then add its filename to your table (subject to copyright restrictions, of course). The above is just meant to be an example of what you can achieve.

Now, having said all that, I suggest you put all this out of your head for two weeks and concentrate instead on enjoying your Baltic holiday.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>Now, having said all that, I suggest you put all this out of your head for two weeks and concentrate instead on enjoying your Baltic holiday.
I second that. Perhaps have a go at this to see the concept works. That helps getting the thought about that open problem out of the way. Just don't be tempted to bring this forward. a holiday, especially a travelling holiday, is to valuable for this, even if this is a hobby and fun project. It doesn't run away, as we say.

Bye, Olaf.
 
@Olaf & Mike: Thank you for the good-will recommendation to take a break during holiday. I will follow your nice guidance as long as it is not raining here and as long as my wife is not sleeping. Meanwhile a chessfriend (my 2nd hobby of 4) has updated his homepage where he had reserved a place with watercolor - paintings made by me :
Link
I am the guy with plaid shirt on the right. If you click below on "Zur Bildergalerie von Klaus Briesemeister" you can see them all. Clicking on the pics will zoom them.
(Would be interested which one you like most, if there is one at all..)

Greetings from Flensburg/Germany

Klaus


Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top