?
Solved

Help ! Web document properties

Posted on 2004-12-01
21
Medium Priority
?
322 Views
Last Modified: 2010-04-05
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

0
Comment
Question by:antenor
  • 7
  • 6
  • 4
  • +1
19 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 672 total points
ID: 12715751
Hi,

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

Regards, Geo
0
 

Author Comment

by:antenor
ID: 12715989
ok, geobul

item 2 - it's ok...


now, item 1 - do you know to execute ?

Tanks
0
 
LVL 17

Expert Comment

by:geobul
ID: 12716567
I have no idea. Sorry.
0
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.

 

Expert Comment

by:Ergin Soysal
ID: 12721004
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
 

Assisted Solution

by:Ergin Soysal
Ergin Soysal earned 664 total points
ID: 12721230
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
 

Author Comment

by:antenor
ID: 12725003
Sorry. I don't  explained correctly.

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


0
 
LVL 26

Assisted Solution

by:Eddie Shipman
Eddie Shipman earned 664 total points
ID: 12729661
0
 
LVL 17

Expert Comment

by:geobul
ID: 12733900
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12736353
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
 
LVL 17

Expert Comment

by:geobul
ID: 12736941
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
 

Author Comment

by:antenor
ID: 12737495
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
 

Author Comment

by:antenor
ID: 12737510
ops, errata...

item 3) of the "I do":

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

0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12738542
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12738570
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12739135
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
 

Author Comment

by:antenor
ID: 12739229
ok Eddie,

provisorly I go using in that way that I made.


0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12739973
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
 

Author Comment

by:antenor
ID: 12753885
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12754179
Problem is, I can not find it in the cache.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 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