Help ! Web document properties

I want interact in a web Form ...

I.e.

<FORM name="pfe" action="result.asp" method=POST target=_top onsubmit="return Envia()">
     <input type="hidden" name="hidFlag" value="0">
     <INPUT TYPE=HIDDEN NAME="serv">
     <INPUT type="text" name="Key" size="4" maxlength="4"></TD>
     <IMG border="0" src="/images/imageGenerator" >
     <INPUT type="submit" name="button" value="Click here" onclick="Verify(2)">
...

1) I want get image from a describe Form ( <IMG border="0" src="/images/imageGenerator" > ) and  load into image component      ;            
2) I want sumit a click event to button ( <INPUT type="submit" name="button" value="Click here" onclick="Verify(2)"> ).

for a ... a value to "Key" variable, i do this:
   " Twebbrowse.OleObject.document.pfe.key.value := '8888'; "
and for a items 1 and 2, how do I proceed ?

Tanks

antenorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

geobulCommented:
Hi,

2. try
Twebbrowse.OleObject.document.pfe.submit;
or
Twebbrowse.OleObject.document.pfe.button.click;

Regards, Geo
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
antenorAuthor Commented:
ok, geobul

item 2 - it's ok...


now, item 1 - do you know to execute ?

Tanks
0
geobulCommented:
I have no idea. Sorry.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Ergin SoysalAssistant ProfessorCommented:
I'm afraid, item 1 is not possible with a single line of code.
One solution (and the best probably) may be hooking TWebbrowser and implement your own temporary pluggable protocol such as "imagegen", and replace image tag as

<IMG border="0" src="imagegen://images/imageGenerator" >

Here is a sample
http://www.euromind.com/iedelphi/app/pluggableprotocol.htm

item 2->
WebBrowser1.OleObject.document.pfe.submit();
0
Ergin SoysalAssistant ProfessorCommented:
He he.. sorry. I found a much simpler one for item 1.

Assign a name to your image:

<IMG name="generatedimage" border="0" src="" >


With Delphi, create your image and save to a local file:

TFileName filename := ExtractFilePath(Application.ExeName) + "temp.jpg";
generateImageToTempFile(filename);

And assign your image's src:
WebBrowser1.OleObject.document.images.item('generatedimage').src := filename;

0
antenorAuthor Commented:
Sorry. I don't  explained correctly.

In the item 2, i want get image from web page and put into TImage component.


0
Eddie ShipmanAll-around developerCommented:
0
geobulCommented:
The problem with getting the image from internet as a file is that there is no such file. It is a server-side script (perhaps) which returns an image.
0
Eddie ShipmanAll-around developerCommented:
Using http get will return the image just fine if it is created in a server side script.
Show me a link to one and I'll show you how it works.
0
geobulCommented:
Sure, but it might be another image due to two different consecuitive calls of the ImageGenerator, one call from the page irself and another one using the way you've proposed.
0
antenorAuthor Commented:
It is a dynamic image (it sees the site http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/sintegra.html ).
I need to directly capture the image of a loaded page for the TWebBrowser component, in other case it is modified.

I do:
1) Webbrowser1.Navigate('http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/sintegra.html');
2) turn off line browser navigation
3) WebBrowser1.OleObject.Document.Images.Item(3).Src;
4) UrlDownloadToFile(nil, PChar(Source), PChar('image.jpeg'), 0, nil);
5) turn on line browser navigation
6) Image1.Picture.LoadFromFile( 'image.jpeg' );

But,  I would like to get the image without making off line and on line, as like to rigth mouse click on the image and to select to "save image as... ".

do you understand?

0
antenorAuthor Commented:
ops, errata...

item 3) of the "I do":

Source := WebBrowser1.OleObject.Document.Images.Item(3).Src;

0
Eddie ShipmanAll-around developerCommented:
Using Indy, I downloaded the image into a TImage control for you.
To modify this to save it to a file instead, just change to use a
TFileStream instead of a TMemoryStream.

procedure TForm1.Button1Click(Sender: TObject);
begin
  WB.Navigate('http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/sintegra.html');
end;

procedure TForm1.WBDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  Source: String;
  JPG : TJPEGImage;
  Stream: TMemoryStream;
  h,w : Integer;
begin
  Source := WB.OleObject.Document.Images.Item(3).Src;
  Label1.Caption := Source;
  // To use URLDownloadToFile, comment out or delete the lines between the //*** markers
  // and uncomment the line below.
  // UrlDownloadToFile(nil, PChar(Source), PChar('c:\antenor.jpg'), 0, nil);
  //***
  w := WB.OleObject.Document.Images.Item(3).width;
  h := WB.OleObject.Document.Images.Item(3).height;
  JPG := TJPEGImage.Create;
  Image1.Width := w;
  Image1.Height := h;
  Stream := TMemoryStream.Create;
  try
    idhttp1.Get(Source, Stream);
    Stream.Position := 0;
    JPG.LoadFromStream(Stream);
    Image1.Picture.Assign(JPG);
  finally
    JPG.Free;
    Stream.Free;
  end;
  //****
end;

However, using  
UrlDownloadToFile(nil, PChar(Source), PChar('c:\geobul.jpg'), 0, nil);
also worked when I needed to save it to a file.

I don't see what your problem is.
0
Eddie ShipmanAll-around developerCommented:
Oh, I see, what's going on now...the code displayed in the webbrowser is not the same as
the one in Image1.

Let me take another look at it...
0
Eddie ShipmanAll-around developerCommented:
I figured I would try finding the image in the cache, however,
I walked the cache and the image is not even there.

I'm going to have to research this a little bit more.
0
antenorAuthor Commented:
ok Eddie,

provisorly I go using in that way that I made.


0
Eddie ShipmanAll-around developerCommented:
But if you do a Stop, to stop the navigtation, how are you going to contunue it? It will load
a different image if you refresh or reload the page.

Each successive call to the imageGenerator will return an image with a new code.
0
antenorAuthor Commented:
exactly,

it was therefore that I placed the navigation in off line and online.
Making offline and online, the image continues in cache and obtains to get the same image, as example below:

procedure TForm1.Get_Image;
const
  INTERNET_STATE_DISCONNECTED_BY_USER = $10;
  ISO_FORCE_DISCONNECTED = $1;
  INTERNET_STATE_CONNECTED = $1;
var
  ci: TInternetConnectedInfo;
  dwSize: DWORD;
  source : string;
  pw : TPicture;

begin
  //Make offline
  dwSize := SizeOf(ci);
  ci.dwConnectedState := INTERNET_STATE_DISCONNECTED_BY_USER;
  ci.dwFlags := ISO_FORCE_DISCONNECTED;
  InternetSetOption(nil, INTERNET_OPTION_CONNECTED_STATE, @ci, dwSize);

  //Get image from the cache
  source := WebBrowser1.OleObject.Document.Images.Item(3).Src;
  UrlDownloadToFile(nil, PChar(Source), PChar('image.jpeg'), 0, nil);

  //Make online
  dwSize := SizeOf(ci);
  ci.dwFlags := 0;
  ci.dwConnectedState := INTERNET_STATE_CONNECTED;
  InternetSetOption(nil, INTERNET_OPTION_CONNECTED_STATE, @ci, dwSize);

  //Load image file to component
  Image1.Picture.LoadFromFile( 'image.jpeg' );
end;

It's work with success !!!

But, if do not existis another way... (i.e. directly get from the cache, without making the commands of offline - online), I go to be with the current solution.
 
0
Eddie ShipmanAll-around developerCommented:
Problem is, I can not find it in the cache.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.