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 

Invoking the events when filling in fields using TCppWebBrow

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





PostPosted: Thu Feb 22, 2007 7:19 am    Post subject: Invoking the events when filling in fields using TCppWebBrow Reply with quote



Hi,

I am filling in a form on a website that invokes events when the field is
changed. When I fill in the form through (say) IHTMLInputTextElement these
events are not invoked.

What do I need to do to get these events to fire?

Regards
Trevor Keegan
Back to top
Eduardo Jauch
Guest





PostPosted: Thu Feb 22, 2007 7:33 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote



Trevor Keegan escreveu:
Quote:
I am filling in a form on a website that invokes events when the field is
changed. When I fill in the form through (say) IHTMLInputTextElement these
events are not invoked.

What do I need to do to get these events to fire?


Take a look at the events.
They must be links or Java functions.

What you can do is when you fill the form, trigger yourself the events. :)

If the event is a link, call the link.

If the event is a java script (what is most common), call it like if it
was a link:

CppWebBrowser->Navigate("javascript:Myfunc()");

Will work :)

Only a tip... If this operation will be done many times, maybe you must
consider using another component...

TCppWebBrowser, being a wraper for the ActiveX of IE is horrible... ;)

But will work for many applications Smile
Back to top
Trevor Keegan
Guest





PostPosted: Thu Feb 22, 2007 7:48 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote



Hi Eduardo,

Thanks for your reply

The problem is I have stuff like this:
class=text id="F00043"
value="TKEEGAN (AT) EALINK (DOT) COM"onChange="javascript:this.value=this.value.toUpperCase();"
OnBlur="return checkEmail(this)"

While this is a fairly simple thing to handle, I am just worried that the
authors will at some point in time change/add stuff to the script...this
will then mean that I have to be aware of these changes. I though that it
would be better if there was some way to force the execution of these
events.

Regards
Trevor Keegan
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 22, 2007 8:03 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45dcef87$1 (AT) newsgroups (DOT) borland.com...

Quote:
What do I need to do to get these events to fire?

Fire them manually. The browser's DOM interfaces provide access to
them.

Events are normally accessed via the IDispatch interface. So, for
example, to fire the onblur event, you would call
IHTMLElement2::get_onblur(), which returns a VARIANT containing an
IDispatch interface. You would then call the IDispatch::Invoke()
method, specifying DISPID_VALUE as the ID to execute.

Alternatively, use the IHTMLElement3::fireEvent() method instead,
which does the above work for you.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 22, 2007 8:03 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45dcf664 (AT) newsgroups (DOT) borland.com...

Quote:
I though that it would be better if there was some way to force
the execution of these events.

There is. See my other reply.


Gambit
Back to top
Eduardo Jauch
Guest





PostPosted: Thu Feb 22, 2007 8:41 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Always learning something new Smile
Good to know Smile
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 22, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45dd392b (AT) newsgroups (DOT) borland.com...

Quote:
I did see the Invoke method there, but it looked as though I needed
to send in a whole bunch of parameters. So I thought there might
be another way Smile

Invoke() is a very flexible method. Just because it has room to
accept parameters does not mean that you have to use them. In fact,
DISPID_VALUE is a default method, so it does not accept any input
parameters. You would fill in the DISPPARAMS structure with empty
data. There is an example in IDispatch's documentation of calling a
method with no parameters.

Quote:
I like the sound of this....but please help me, how do I get
to the IHTMLElement3....

The same way you get any interface from another - via the
QueryInterface() method.

Quote:
I current have this:
snip
Should I add something like IHTMLElement3::fireEvent( "OnBlur",
TextInput )
?

Please read the documentation for fireEvent():


http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/element3/fireevent.asp


Gambit
Back to top
Trevor Keegan
Guest





PostPosted: Thu Feb 22, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Hello Remy,

I did see the Invoke method there, but it looked as though I needed to send
in a whole bunch of parameters. So I thought there might be another way :)

Quote:
Alternatively, use the IHTMLElement3::fireEvent() method instead,
which does the above work for you.
I like the sound of this....but please help me, how do I get to the

IHTMLElement3....I current have this:

TComInterface<IHTMLInputTextElement> TextInput;
Disp->QueryInterface( IID_IHTMLInputTextElement,
(LPVOID*)&TextInput );

if( TextInput )
{
//Set the value in the field
TextInput->put_value( WideString( Value ) );
}

Should I add something like IHTMLElement3::fireEvent( "OnBlur", TextInput )
?

Regards
Trevor Keegan
Back to top
Trevor Keegan
Guest





PostPosted: Fri Feb 23, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Hello Remy,

Thanks for your help :-)

I am sure that there is something fundamental that I am missing here. When
I try to compile the code:
TComInterface<IHTMLElement3> Element;
The comiler complains basically telling me that it does not know what an
IHTMLElement3 is. I have found other types (e.g. IHTMLTextElement) in th
comdef.h header file...but not the IHTMLElement3.

I am using Builder 6, is there something that I need to do that I am not
doing?

Regards
Trevor Keegan
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Feb 23, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45de9306 (AT) newsgroups (DOT) borland.com...

Quote:
When I try to compile the code:
TComInterface<IHTMLElement3> Element;
The comiler complains basically telling me that it does not
know what an IHTMLElement3 is.

IHTMLElement3 is not defined in the SDK headers that ship with BCB 6.
You will have to declare the interface manually in your own code.
Alternatively, import mshtml.tlb into the IDE and have it generate
MSHTML_TLB.cpp and MSHTML_TLB.h files that you can use.


Gambit
Back to top
Trevor Keegan
Guest





PostPosted: Fri Feb 23, 2007 3:58 pm    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Hello Remy

OK....I have imported the library using:
tlibimp -Hs- -Hr- -Fe- \windows\system32\mshtml.tlb......And I can see that
it has created the IHTMLElement3 interface for me :)

The problem that I have now is that code that was compiling ok....now does
not compile....in particular the compiler now complains that the put_value
is not a member of the IHTMLInputTextElement......but it is according to
http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/inputtextelement/inputtextelement.asp

TComInterface<IHTMLInputTextElement> TextInput;
Disp->QueryInterface( IID_IHTMLInputTextElement,
(LPVOID*)&TextInput );

if( TextInput )
{
//Set the value in the field
TextInput->put_value( WideString( Value ) );
}

The problem appears to be now that I have 2 mshtml.h files. The original
one and the new one, is this correct?

Regards
Trevor Keegan
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 24, 2007 12:35 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45debab4 (AT) newsgroups (DOT) borland.com...

Quote:
The problem that I have now is that code that was compiling ok....
now does not compile....in particular the compiler now complains
that the put_value is not a member of the
IHTMLInputTextElement......


Look at the declaration of the IHTMLInputTextElement interface in the
headers. What do you actually see?


Gambit
Back to top
Trevor Keegan
Guest





PostPosted: Sun Feb 25, 2007 8:53 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Hello Remy,

Quote:
The problem that I have now is that code that was compiling ok....
now does not compile....in particular the compiler now complains
that the put_value is not a member of the
IHTMLInputTextElement......

Look at the declaration of the IHTMLInputTextElement interface in the
headers. What do you actually see?
I have taken a look and now see what the problem is.....it appears as though

all the put methods (e.g. put_value) have now been changed to set methods
(i.e. set_value). I recently upgraded to IE 7, I guess that this must been
the cause of this.

Regards
Trevor Keegan
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

"Trevor Keegan" <tkeegan (AT) ealink (DOT) com> wrote in message
news:45e0fa15 (AT) newsgroups (DOT) borland.com...

Quote:
I have taken a look and now see what the problem is.....it appears
as though all the put methods (e.g. put_value) have now been changed
to set methods (i.e. set_value). I recently upgraded to IE 7, I
guess
that this must been the cause of this.

No. Interface methods are not changed once exposed. That is a core
rule of COM programming in order to ensure backwards compatibility
when releasing new versions of a library. Are you sure that you are
actually accessing the interface directly, and not the VCL wrapper
that the IDE generated for you?


Gambit
Back to top
Trevor Keegan
Guest





PostPosted: Mon Feb 26, 2007 9:10 am    Post subject: Re: Invoking the events when filling in fields using TCppWeb Reply with quote

Hello Remy,

Quote:
No. Interface methods are not changed once exposed. That is a core
rule of COM programming in order to ensure backwards compatibility
when releasing new versions of a library. Are you sure that you are
actually accessing the interface directly, and not the VCL wrapper
that the IDE generated for you?
Umm, now that you mention it I had assumed that the correct files would be

generated would be given the correct thing.....I assume for a start that I
am importing it the correct way (so it might be that I am not using the
correct method). I notice that the original mshtml.h (in the
Cbuilder6\include directory) was only about 1.5Mb in size......the newly
generated one is a massive 19.4mb in size. There were 2 header files
generated.....a MSHTML.H file (19.4mb) and a MSHTML_OCX.H file (only 6kb) in
size.

Regards
Trevor Keegan
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.