Lazarus
Programming => Operating Systems => Windows CE => Topic started by: bambamns on May 27, 2012, 02:58:18 pm
-
Hi,
Is it possible to use this method http://wiki.freepascal.org/LazActiveX#TActiveXContainer_early_binding (http://wiki.freepascal.org/LazActiveX#TActiveXContainer_early_binding) for WinCE to make WebBrowser (WM 6.5) ?
If not, how can it be done ?
Thx
-
Not yet.
There are some problems with cross-compiling the lazactivex package which I have solved. The Webbrowser runs but I have some problems with attaching the event sink. Don't know if this a problem linked to the WM6 emulator I'm using or something else. I'll have to try with other ActiveX components. Unfortunately I don't have a real device (other than an old PocketPC 2002).
Extracted the typelibs from browser.dll and webview.ddl and that seems to work fine. Note that a lot of the interfaces are different compared to the desktop.
-
Patches to lazarus and fpc have been made to make lazactivex work on WinCE. They can be found here:
http://bugs.freepascal.org/view.php?id=22152
http://bugs.freepascal.org/view.php?id=22156
http://bugs.freepascal.org/view.php?id=22157
You need to get the dll's from your WM device on your computer to create the typelib units.
It also appears that the WM COM implementation has dropped some of the features found on the desktop. For example the use of onull Olevariant that is initialised to NULL in the Navigate2 call isn't working on WM. The function requires a var parameter but WM accepts or a nil address or a real value. So instead of the onull solution you have to use the ugly 'POleVariant(nil)^' as parameter for Navigate2.
If interested I can create a small demo similar to the one on the wiki page and attach the typelib units I obtained from WM 6.1 dll's.
-
Thx,
I have a few utilities written in Lazarus (win32) for access to web an read some PHP data, analyze it, and present to user only the most important information from page (content from page is always the same, there are only a few changes every day).
It will be very helpful to have an WinCE version and to do it I had to use activex like I use it on win32.
Application use Events OnNavigateComplete2 and OnDocumentComplete.
If interested I can create a small demo similar to the one on the wiki page and attach the typelib units I obtained from WM 6.1 dll's.
I'll like it a lot - it will be very helpful ::)
If it is not a trouble, it will be helpful to write a few steps how to copy dll from WinCE and which one (couse I use WM 6.5).
Are those patches only for FPC 2.7.1 (a had a few problems when I'd used latest SVN and FPC 2.7.1 for WinCE - best result I'd reached ware with latest SVN and FPC 2.6.1) ?
Thank you.
-
Are those patches only for FPC 2.7.1 (a had a few problems when I'd used latest SVN and FPC 2.7.1 for WinCE - best result I'd reached ware with latest SVN and FPC 2.6.1) ?
IIRC all patches so far related to ActiveX where back-ported to 2.6.1. So, yes, the patches should also work on 2.6.1.
For the missing stdole2 and eventsink units, you can just copy the source files from the fpc packages\winunits-base\src directory in your project directory. Make sure you apply the patch for eventsink though.
A small sample program to illustrate the use of the webbrowser on wince is attached. It navigates to a page stored in the file system and writes the urls received in OnNavigateComplete2 and OnDocumentComplete to a TMemo. Note the use of POleVariant(nil)^ to pass NULL values as var parameter. Using a variant initialised to NULL causes a 'invalid parameter error' which isn't a very useful message. Also the PIEWebBrowser class has IWebBrowser as the default interface and IWebBrowser2 as a hidden interface (IWebBrowser.Navigate versus IWebBrowser2.Navigate2). If you need to access the IWebBrowser2 methods or properties use something like this: var
ourl:Olevariant;
Browser2:IWebBrowser2;
...
ourl:=Utf8decode('file://\Storage%20Card\readme.htm');
Browser2:=(Browser.ComServer as IWebBrowser2);
Browser2.Navigate2(ourl,polevariant(nil)^,polevariant(nil)^,polevariant(nil)^,polevariant(nil)^);
The zip file also contains PIEBrowser_1_0_TLB and WEBVIEWLib_2_0_TLB that correspond to the wm 6.1 browser.dll and webview.dll I got hold of. They'll probably work fine on wm6.5.
There is no easy way to get to the rom dll's. There are some utilities that allow you to extract files from ROM. Google is your best friend ;)
-
Thx,
It's working on WM 6.5, but ....
If I wont to read content of html on win32 I use :
Var Doc: IHTMLDocument2; <- this is from MSHTML_4_0_TLB - does WinCE has it ?
begin
doc := Browser.ComServer.Document as IHTMLDocument2;
memo2.lines.add(Doc.parentWindow.document.Get_body.innerText);
But on WinCE it's not working - on compile I get error - Identifier not found.
Thank you again, a lot.
-
Var Doc: IHTMLDocument2; <- this is from MSHTML_4_0_TLB - does WinCE has it ?
No. But I gave you also WEBVIEWLib_2_0_TLB which is the equivalent of MSHTML_4_0_TLB. As I noted before the interfaces are quite different on wince.
IHTMLDocument2 becomes IPIEHTMLDocument2
Get_body is not available in IPIEHTMLDocument2 but added in IPIEHTMLDocument4 so some runtime interface querying is needed (the 'as' operator). Runtime queries can fail. So good practice is to check if the interface exists before continuing.
Your code becomes:
var
doc:IPIEHTMLDocument2;
begin
doc := Browser.ComServer.Document as IPIEHTMLDocument2;
Memo2.Lines.Add((doc.parentWindow.document as IPIEHTMLDocument4).body.innerText);
Note that on the WM6 emulator the call to 'body' (or Get_body) raises an Ole Exception. I also tried to get 'body' using variants (late binding) and the object doesn't seem to implement it. I did a quick Google on this problem and it seems there are dlls/roms around where 'body' indeed fails (http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/bef6dc38-0dd9-4f97-8813-efbcc7b16414)
Let me know if this works for you.
-
Yes, thank you - it is working.
I had to copy oleserver.pp in project folder, because stdole2.pas is using it.
There is one duplicated property in line 1921 of VEBVIEW (I'd comment out it)
// property title:WideString writeonly dispid 4238;
Sometimes it reads text, sometimes it crash (like you wrote).
If you find way to fix reason for crashing, write it.
I noticed that
procedure TForm1.OnNavigateComplete2(Sender: TObject; pDisp: IDispatch;
var pvtURL: OleVariant);
begin
Memo1.Lines.Add('NavigateComplete2');
label1.Caption := Browser.ComServer.LocationURL;
end;
is working and it gives some strange ascii strings beside url, but
procedure TForm1.OnStatusTextChange(Sender: TObject;Text_:WideString);
begin
Label2.Caption := Text_;
end;
is not working at all.
I'll try to find browser.dll and webview.dll for WM 6.5 - maybe it will fix some things.
-
If you find way to fix reason for crashing, write it.
I did some further testing since the late binding crashing also is very suspect. Called the IDispatch functions directly (GetIDsOfNames and Invoke) for the body property. GetIDsOfNames returns the correct dispid but Invoke with the id and DISPATCH_PROPERTYGET is causing an unexepexted error. So I'm afraid there isn't very much else that can be done.
OnStatusTextChange ... is not working at all.
Yes. I traced all dispid's sent to the eventsink and none corresponds with OnStatusTextChange. There where a few unknown dispid's received but they don't correspond with OnStatusTextChange. OnStatusTextChange is triggered on a desktop when hovering over a link. On wince no event is received when doing so. Have you already seen a working status bar in the wince IE? Possibly the status message has to be enabled (similar to address bar).
I had to copy oleserver.pp in project folder, because stdole2.pas is using it.
There is one duplicated property in line 1921 of VEBVIEW (I'd comment out it)
OK. I'll look into that.
I'll try to find browser.dll and webview.dll for WM 6.5 - maybe it will fix some things.
One of the rules for COM is that interfaces can't change. So whatever is declared in the binding is correct. Possibly 6.5 defines new interfaces. I created also the tlb for 6.0 and in comparison with the 6.1 there are a few hundred new lines in 6.1 but I have found no changes in the existing ones.
-
So I'm afraid there isn't very much else that can be done.
I hope there is - do you need some examples or anything that can help to solve this puzzle ?
Have you already seen a working status bar in the wince IE?
Your are write - there is no status bar.
Possibly the status message has to be enabled (similar to address bar).
No , there is not such a setting.
One of the rules for COM is that interfaces can't change.
Yes , I know ....
If you find any further fix/option for ActiveX on WinCE, please inform us.
Thank you.
-
Finally got it working. The main problem was that I tried several things in OnNavigateComplete2 but the dom isn't completely parsed yet. The 'unspecified error' didn't help a lot there :(
In OnDocumentComplete the following works perfectly:
Memo2.Lines.Add((doc.parentWindow.document as IPIEHTMLDocument4).body.innerText);
or if you want the complete html
Memo2.Lines.Add((doc as IPIEHTMLDocument3).documentElement.innerHTML);
-
Yea, you are write.
I made button for reading inner text , but I didn't waited OnDocumetComplete to be fired.
It is ok Now, THX a lot
Keep good work