BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Find and click a link with CppWebBrowser

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web)
View previous topic :: View next topic  
Author Message
Eduardo Jauch
Guest





PostPosted: Fri Feb 02, 2007 12:15 am    Post subject: Find and click a link with CppWebBrowser Reply with quote



I loaded a page in my program using TCppWebBrowser, that cointais these
lines (among many others):

<a href="javascript: confirmarInformacoesDeVisto();">
<img src="bt_voltar.gif" border="0"></a>&nbsp;

<a href="javascript: confirmarAgendamento();">
<img src="bt_confirmar.gif" border="0"></a>&nbsp;

<a href="javascript: listaSituacaoAgendamento();">
<img src="bt_cancelar.gif" border="0"></a>


How can I execute by program the second line?
I mean, how can I "simulate" by my program the click of the mouse in the
specified link by a user?

I saw a code on another post that execute a "click" on a button (by Remy).

#include <mshtml.h>
#include <utilcls.h>

if( CppWebBrowser1->Document )
{
TComInterface<IHTMLDocument2> Doc;
CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);

if( Doc )
{
TComInterface<IHTMLElementCollection> All;
Doc->get_all(&All);

if( All )
{
TComInterface<IDispatch> Disp;
All->item(TVariant(WideString("secure_exit")),
TVariant(0), &Disp);

if( Disp )
{
TComInterface<IHTMLElement> Element;
Disp->QueryInterface(IID_IHTMLElement,
(LPVOID*)&Element);

if( Element )
Element->click();
}
}
}
}

But in this example, the "button" has a name,

<input TYPE="button" NAME="secure_exit" VALUE=" Finished "
onClick="logout();">

And my "links" don't have...
So, how to FIND the right link in the page and how to execute it?
Back to top
Eduardo Jauch
Guest





PostPosted: Sat Feb 03, 2007 2:08 am    Post subject: Re: Find and click a link with CppWebBrowser Reply with quote



I saw in another post (that I can't remember where), that Javascript can
be put in Navigate like a URL...

So I don't need to find my links, I need only to execute a new Navigate
to that link...

Like:

Browser->Navigate(WideString("javascript: myfunc()"));

But anyway, how to find the links in the page?

Thanks Smile
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Mar 23, 2007 8:10 am    Post subject: Re: Find and click a link with CppWebBrowser Reply with quote



"Eduardo Jauch" <eduardo.jauch (AT) gmail (DOT) com> wrote in message
news:45c22e07 (AT) newsgroups (DOT) borland.com...

Quote:
So, how to FIND the right link in the page and how to execute it?

The IHTMLDocument2 interface has an "anchors" collection that you can
access.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.