Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TWebBrowser and Submit.Form issue?

Posted on 2004-10-26
3
Medium Priority
?
278 Views
Last Modified: 2010-05-18
Hello All;

 I am using the following code to click the [Submit] button on my site.
VIA the TWebBrowser ( TEmbeddedWB).  This works great, except it has a problem?
After it click the [Submit] Button, and the next page opens, I get an
Exception. It is trying to [Submit] the page again.

  I have used this code before, and have never had this problem before.
And now ?? I do not know ??

Provided is the Code that I am using.
Below the Code will be the " Exception " that I received on the next page.

==+==+==+==+==+==+==++=+==+==+=++=+==+==+==
add to [Uses :  MSHTML_TLB; ]

procedure TProject1.AdminWebDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  AdminSubmit : IHTMLInputElement;
  MyDocument : IHTMLDocument3;
begin
   MyDocument := AdminWeb.Document as IHTMLDocument3;
   if Assigned(MyDocument) then
   begin
   AdminSubmit := (MyDocument.getElementsByName('Admin_Login').item(0,'')as
IHTMLInputElement);
   AdminSubmit.Form.Submit;
end; end;
==+==+==+==+==+==+==++=+==+==+=++=+==+==+==

Exception

---------------------------
Debugger Exception Notification
---------------------------
Project Project.exe raised exception class EAccessViolation with message
'Access violation at address 00483C79 in module 'Project.exe'. Read of
address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help
---------------------------

It lands on
==+==+==+==+==+==+==
AdminSubmit.Form.Submit;
==+==+==+==+==+==+==

Any idea's on how to make this code work to where it only executes
When the " Username & Password " form is presented?
And not on pages that do not require it?

Thank you all in advance.
Carrzkiss
0
Comment
Question by:Wayne Barron
[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
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 12419552
Hi,

Try checking if that InputElement exists in the document:

   AdminSubmit := (MyDocument.getElementsByName('Admin_Login').item(0,'')as IHTMLInputElement);
   if Assigned(AdminSubmit) then  AdminSubmit.Form.Submit;

As far as I can see that is an event handler for your WebBrowser OnComplete event and it's being called for all pages you're navigating.

Regards, Geo
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 12422195
Thank you so very much [Geobul];

Adding the
is assigned(AdminSubmit) then

right before -  AdminSubmit.Form.Submit;

Did the trick.

Once again, thank you very much.

Carrzkiss
0
 
LVL 17

Expert Comment

by:geobul
ID: 12422453
The pleasure was mine :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…
Suggested Courses

636 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