IT79637
asked on
How to move data between EWB and Delphi vairable?
Hi,
I'm on a WinXP Pro SP3 box using Delphi 7.
I'm trying to integrate a web browser with a Delphi application in the same executable.
I downloaded and installed the Embedded Web Browser (EWB) component from www.bsalsa.com/product.html.
When I run a web based business application using EWB, is it possible to move data between the EWB HTML text fields and Delphi variables? If so how is it done?
Thank you.
I'm on a WinXP Pro SP3 box using Delphi 7.
I'm trying to integrate a web browser with a Delphi application in the same executable.
I downloaded and installed the Embedded Web Browser (EWB) component from www.bsalsa.com/product.html.
When I run a web based business application using EWB, is it possible to move data between the EWB HTML text fields and Delphi variables? If so how is it done?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
This is my first attempt to move data between Delphi and TWebBrowser control. I got the code from:
http://www.cryer.co.uk/brian/delphi/twebbrowser/read_write_form_elements.htm
I selected the function to list all the fields on a web page. I copied the function: function GetFormFieldNames(fromForm : IHTMLFormElement): TStringList; to the bottom of the Unit1.pas file. Additionally I added MSHTML to my Uses statement. From the IDE menu, I selected --> Project, Project Options, Directories/Conditionals and added the directory where MSHTML.pas and MSHTML.dcu are located to the "Search Path".
I added my own Button OnClick event and copied the www.cryer.co.uk code directly into my program. When I compile and run the code I get several errors.
Please see the screen shot below.
What have I neglected to do?
Thanks much.
This is my first attempt to move data between Delphi and TWebBrowser control. I got the code from:
http://www.cryer.co.uk/brian/delphi/twebbrowser/read_write_form_elements.htm
I selected the function to list all the fields on a web page. I copied the function: function GetFormFieldNames(fromForm
I added my own Button OnClick event and copied the www.cryer.co.uk code directly into my program. When I compile and run the code I get several errors.
Please see the screen shot below.
What have I neglected to do?
Thanks much.
ASKER
Upped points.
ASKER
Lost Code and Image when I clicked Rich Test. Both are available below.
procedure TForm1.btnListFieldsClick(Sender: TObject);
var
document: IHTMLDocument2;
theForm: IHTMLFormElement;
index: integer;
begin
document := WebBrowser1.Document as IHTMLDocument2;
theForm := GetFormByNumber(WebBrowser1.Document as IHTMLDocument2,0);
fields := GetFormFieldNames(theForm);
for index := 0 to fields.count-1 do
ShowMessage('Field ' + IntToStr(index) + ' called ' + fields[index]);
end;
function GetFormFieldNames(fromForm: IHTMLFormElement): TStringList;
var
index: integer;
field: IHTMLElement;
input: IHTMLInputElement;
select: IHTMLSelectElement;
text: IHTMLTextAreaElement;
begin
result := TStringList.Create;
for index := 0 to fromForm.length do
begin
field := fromForm.Item(index,'') as IHTMLElement;
if Assigned(field) then
begin
if field.tagName = 'INPUT' then
begin
// Input field.
input := field as IHTMLInputElement;
result.Add(input.name);
end
else if field.tagName = 'SELECT' then
begin
// Select field.
select := field as IHTMLSelectElement;
result.Add(select.name);
end
else if field.tagName = 'TEXTAREA' then
begin
// TextArea field.
text := field as IHTMLTextAreaElement;
result.Add(text.name);
end;
end;
end;
end;
HTML5.jpg
ASKER
Thanks.