Recent

Author Topic: Fill data on HTML with ActiveX  (Read 3360 times)

bambamns

  • Full Member
  • ***
  • Posts: 223
Fill data on HTML with ActiveX
« on: September 27, 2012, 02:32:57 pm »
Hi,

I have a site with some fields witch user fill and then press button to save those data.
Some user use web to fill those data, but I have made an windows application to fill those data and press button on site - Everything is working fine.

Now I need to make application for WM 6.5 and I did it but I have a problem with following lines :

On desktop windows  I have (and it works) :

Code: [Select]
Var Browser:TEvsWebBrowser;
      Doc: IHTMLDocument2;
      WebForm: IHTMLFormElement;
      FormElements: OleVariant;
      _data: variant;   
      url,onull:Olevariant; 

      Browser:=TEvsWebBrowser.Create(Self);
      ActiveXContainer.ComServer:=Browser.ComServer;
      ActiveXContainer.Active:=true;
 
      url:=Utf8decode('http://url.com');
      onull:=NULL;
      Browser.ComServer.Navigate2(url,onull,onull,onull,onull); 

      doc := Browser.ComServer.Document as IHTMLDocument2;
      _data := '123456';

      WebForm := Doc.Forms.Item(0,'') as IHTMLFormElement;
      FormElements := WebForm.Elements;
      FormElements.Item(4).Value := _data; // fill data
      FormElements.Item(5).Click;  // press button


Same code I wrote for WM 6.5 "

Code: [Select]
Var    Browser:TEvsPIEWebBrowser;
         url:widestring;
         Doc: IPIEHTMLDocument2;
         WebForm: IPIEHTMLFormElement;
         FormElements: OleVariant;
         _data: variant;

        Browser:=TEvsPIEWebBrowser.Create(Self);
        ActiveXContainer1.ComServer:=Browser.ComServer;
        ActiveXContainer1.Active:=true;                       

      url := 'http://url.com';
      Browser.ComServer.Navigate(url,polevariant(nil)^,POleVariant(nil)^,polevariant(nil)^,polevariant(nil)^);

      doc := Browser.ComServer.Document as IPIEHTMLDocument2;
      _data := '12465';
 
      WebForm := Doc.Forms.Item(0,'') as IPIEHTMLFormElement; <- this make exception on WM 6.5                                                                   
                                                                                          Exception =  Bus error or misaligned data access
 
      // this is the part I cannot test
      FormElements := WebForm.Elements;
      FormElements.Item(4).Value := _data;
      FormElements.Item(5).Click;
     


I had tried to declare  and use :
Code: [Select]
Doc: IPIEHTMLDocument;
...
doc := Browser.ComServer.Document as IPIEHTMLDocument;

But I get the same error.

Any clue ?

Thx
« Last Edit: September 27, 2012, 02:41:49 pm by bambamns »
Lazarus 1.8.4 + FPC 2.6.4 x86 (rebuild) and Lazarus 2.0, Windows 7 x64, unless otherwise specified