[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

webbrowser control events

avi

3/6/2012 12:05:00 PM

Is there some event that the users has control on (such as double
click, Mouse_down...) that will fire some event for a visible
webbrowser on a form?


Thanks
Avi
6 Answers

Larry Serflaten

3/6/2012 1:17:00 PM

0

avi wrote:
> Is there some event that the users has control on (such as double
> click, Mouse_down...) that will fire some event for a visible
> webbrowser on a form?

A little more clarity is needed. A webrowser on a form will act like
a web browser. If the user clicks on a link, they go to the link. If
the page has script behind a button, the script runs when the button
is clicked.

Did you mean you want some sort of form event called when the user
interacts with the web browser?

LFS

Mayayana

3/6/2012 2:25:00 PM

0

| Is there some event that the users has control on (such as double
| click, Mouse_down...) that will fire some event for a visible
| webbrowser on a form?
|
Generally you'd want to use the Document. The IE
DOM is available. So there's click, right-click, etc.
but they're registering through the current Document.

The WB is basically the same as IE. You'd be interested
in events like DocumentComplete, and maybe window
details, but the person is never actually relating to the
WB. They're relating to the document in it.

Unfortunately, Microsoft has drastically damaged the
DOM in later versions of WB/IE. Since they introduced
"quirks mode" rendering there are actually two possible
DOMs. One is the old type. The newer one is more
standards-compliant. Which one is in effect depends on
whether a DOCTYPE tag or MS-specific META tags let
IE know that the page is non-quirks. The damage is that
the two DOMs are mutually exclusive. That may not
apply directly to events. I'm not sure. But it's something
you need to be aware of if you're working with the
DOM. Here's a typical example of what is sometimes
required to use the DOM now:

If WB.document.compatMode = "CSS1Compat" Then
MsgBox WB.document.documentElement.innerHTML
Else
MsgBox WB.document.body.innerHTML
End If

Notice how you can test it with CompatMode? They
broke that too!

"The IHTMLDocument5::compatMode property is deprecated in Internet Explorer
8 in favor of the IHTMLDocument6::documentMode property."

I do all web design with no DOCTYPE tag, which gives
me a very consistent behavior across all versions of IE.
But if you're not controlling the webpage then you have
to be aware of "document mode", and also of the various
broken compatibility items that MS introduces in *every*
version of IE.


Schmidt

3/6/2012 4:13:00 PM

0

Am 06.03.2012 14:17, schrieb Larry Serflaten:
> avi wrote:
>> Is there some event that the users has control on (such as double
>> click, Mouse_down...) that will fire some event for a visible
>> webbrowser on a form?
>
> A little more clarity is needed....

I think there's a chance, that this question is related to
his last one (about "Geo-Maps and stuff") ...

So (@avi) ... are you now trying to use/manipulate (or interact
with) an online-map (provided by Google or MS) using the IE-Control?

If yes, could you describe a bit more what you really want
to do with (or on) such Geo-Images?

You wrote that you want to:
"add to the country area/state/city some data or
color scheme depending on some value or criteria"

That's a bit vague ... in case you want to overlay your own:
- "semitransparent Polygon-based areas" ... or
- "Polygon-based Lines to show routes" ... or just
- "colored markers, based on simple Points"
then all these Coordinates would need to be in Geo-
Coords (Latitude/Longitude-based), to be able to
interact correctly on such Maps.

Olaf

Larry Serflaten

3/6/2012 4:34:00 PM

0

avi wrote:
> Is there some event that the users has control on (such as double
> click, Mouse_down...) that will fire some event for a visible
> webbrowser on a form?


See if this helps:

http://msdn.microsoft.com/en-us/library/i...(v=vs.85).aspx

LFS

Mayayana

3/6/2012 8:48:00 PM

0

Following is a sample webpage that shows how you
can create a transparent rectangle on a webpage,
defined by where mouse-down and mouse-up happen.
(For some reason this sample sometimes requires a click
in between drawing operations. I haven't figured out
that glitch.)

For the sample, put the code into an HTML file and
adjust the part that says "ice1024.jpg". That image
spec should point to a 1024 x 768 image in the same
location as the webpage. The rectangle itself is a
DIV that's not visible until mouse-up.

There are different ways you could do this. There are
also options to create elements dynamically. But however
you go about it you'll probably need to spend some time
fiddling with the DOM. It's amazingly flexible, but also
quirky. It often takes a lot of trial and error to get something
to work they way you want it to.


<HTML>
<HEAD>
<TITLE></TITLE>
<STYLE>
#Div1 {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20);
background-color: #FF0000; display: none;}
</STYLE>


<SCRIPT LANGUAGE="VBScript">
Dim PtX1, PtX2, PtY1, PtY2

Sub Pic1_onmousedown()
PtX1 = window.event.clientX
PtY1 = window.event.clientY
PtX2 = 0
PtY2 = 0
End Sub

Sub Pic1_onmouseup()
PtX2 = window.event.clientX
PtY2 = window.event.clientY

If (PtX1 <> PtX2) And (PtY1 <> PtY2) Then
With Div1.style
.display = "block"
.position = "absolute"
If PtX1 < PtX2 Then
.left = PtX1
.width = PtX2 - PtX1
Else
.left = PtX2
.width = PtX1 - PtX2
End If
If PtY1 < PtY2 Then
.top = PtY1
.height = PtY2 - PtY1
Else
.top = PtY2
.height = PtY1 - PtY2
End If
.zIndex = 10

End With
End If
End Sub

</SCRIPT>
</HEAD>
<BODY>
<DIV ID="Div1"></DIV>
<DIV ID="Pic1" STYLE="width: 1024px; height: 769px; background-image:
url(ice1024.jpg);"</DIV><BR>
</BODY></HTML>


Mayayana

3/6/2012 10:15:00 PM

0

An additional note needed for a WB:

With a webpage you can reference the document
from the page script. With a WB in VB you don't have
anything like a Document_mousedown sub. To get
those events you can declare a document object
withevents:

Private WithEvents Doc1 As HTMLDocument

You'll then need to update the object with each load
because it's not the same object each time. So, with
the WB's DocumentComplete event you need to do
something like this:

Set Doc1 = Nothing
If Not WB.Document Is Nothing Then
Set Doc1 = WB.Document
End If

You can then have something like:

Private Sub Doc1_onmousedown()