WebGadget: Directly insert code and catch link clicks.

Share your advanced PureBasic knowledge/code with the community.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

Dare wrote:I am getting the same crash with invalid memory access.

Code: Select all

If DocumentDispatch\QueryInterface(?IID_IHTMLDocument2, @WebGadget_Document.IHTMLDocument2) = #S_OK
Windows XP pro, just using the include and the example originally posted.

Don't have a clue as to how to fix it.
i found whats actually causing the error, it this line:

Code: Select all

If Browser\get_Document(@DocumentDispatch.IDispatch) = #S_OK
because event tho it gets past the If, it doesnt actually fill the variable with the interface....

i have no idea how to fix this particular error; it only seems to happen in unicode mode...
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

It appears, that when there is actually no document object to return, (for
example there is no page, or it is not fully loaded)
this method actually returns #S_OK, but leaves the pointer at 0.
This is not common COM behaviour. Its quite weird in fact.

Just check in an extra If that DocumentDispatch is not 0 and it should be fine.

I actually added this check in one place, but forgot it in another.
The file linked in my first post is now updated. sorry about this.
quidquid Latine dictum sit altum videtur
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

thanks, now it works fine (i added in the If manually coz ive made mods to the code myself), although, if the webgadget isnt opened with the about:blank url, it doesnt open correctly.... (webgadget_open function)
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

I just checked this code with IE7 because I have started a little project which will
benefit from a web-like GUI, and it works, but not if compiled into unicode.

In that case webGadget_open() always returns 0. Hope you can fix it.

EDIT: http://www.purebasic.fr/english/viewtopic.php?t=25886
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

I've been trying this with custom HTML code. I load it into the webgadget with SetGadgetItemText, wait until webgadget finishes loading, then set the CatchLinks callback.

It correctly gets the number of hyperlinks (you can see this in the "LinkCount" variable) but then it crashes!

This is not being done in a thread, by the way.

The hyperlinks are nothing special, either. They're just dummy links to obvious stuff like hotmail, yahoo etc.

Is it necessary to use the "Webgadget_Open" function with the CatchLinks function?

My computer is Windows XP-Professional SP2. It is not connected to the internet - could that be the problem?
Post Reply