Solved

Internet Explorer_server

Posted on 2006-07-11
18
450 Views
Last Modified: 2007-12-19

in the last post from kiranvj in this Q:
http://www.experts-exchange.com/Programming/Q_21903793.html
he talks about "Internet Explorer_server" that can be used in programs


can someone explain to me how to use this in visual basic because this sounds very interesting...


mark
0
Comment
Question by:Mark_FreeSoftware
  • 8
  • 4
  • 3
  • +1
18 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 130 total points
Comment Utility
i think he is referring either to the 'shdocvw.dll' component part of windows and/or the InternetControl (webBrowser) in the common controls library. Check out you 'References' and 'toolbox components' for ways to add them

After drawing a webbrowser onto your form you can

webbrowser1.Navigate("C:\") 'to display a folder listing like explorer does

or

webbrowser1.Navigate("C:\test.html")  ' to display a html file like IE does

This was part of the argument that Netscape and the US D.o.j had with MS about IE many years ago.. IE is basically the same thing as explorer, it uses the same underlying components to display listings, thats why they couldnt take it out of windows 98 and above becauseit was all 'sewn together'

.NET (2.0 at least ) has an equivalent control called WebBrowser that performs basically the same function (because it is using basically the same underlying library - shdocvw.dll)



0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

can i create a webpage using vb and display it without having to save it somewhere?

also,
do i need to ditribute this component with my program?
0
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
>>can i create a webpage using vb and display it without having to save it somewhere?

yes or no.
All web pages display in IE is stored in Temporary internet directory

>>do i need to ditribute this component with my program?
I believe it comes with the system
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

how can i see on what button is clicked?
eg, i want to create a button,
and style it so it looks nice etc.

how can i post back to vb that a button is clicked?



also:
if the user disabled javascript on his computer, can i use javascript in the interface?
0
 
LVL 2

Assisted Solution

by:daniel_j_c
daniel_j_c earned 185 total points
Comment Utility
try this out:

dump a webbrowser control on your form and add a reference to 'microsoft html object library'
then dump this code in the form:

Option Explicit

'you need to add a reference to 'microsoft html object library' to get this defined
Dim WithEvents oDoc       As HTMLDocument
Dim WithEvents oElement   As HTMLInputElement

Private Sub Form_Load()

 WebBrowser1.Navigate2 "www.google.com"
 
End Sub

Private Sub oDoc_onkeydown()

  Debug.Print Chr(oDoc.parentWindow.event.keyCode) & " pressed"
 
End Sub

Private Sub oElement_onkeydown()
 
 Debug.Print Chr(oDoc.parentWindow.event.keyCode) & " pressed "
 
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

 'you can't hook the dom before this because a fresh one is created when
 'you browse to a new url
 Set oDoc = WebBrowser1.Document
 Set oElement = oDoc.getElementsByName("q").Item(0)
 
End Sub


this will give you events on the dom as a whole but you can also get events on specific elements - the line:
 Set oElement = oDoc.getElementsByName("q").Item(0)
hooks the textbox control you type your query in in google and you can then access a wide range of events.
when an event occurs, you won't be passed parameters in the event, instead you have to look at oDoc.parentWindow.event to get the details

hope that helps!
 
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

ok, we are getting somewhere,

now consider this one:

Option Explicit
Const strPage As String = "<head><style type=""text/css"">.TestBtn {font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF;background-color: #333333;border: 1px solid #FF0000;}</style>" & vbCrLf & _
"</head><body><input name=""btn1"" type=""button"" class=""TestBtn"" value=""Test1""></body>"

Dim WithEvents oTest As HTMLButtonElement
Dim WithEvents oDoc As HTMLDocument
Private Sub Form_Load()
WebBrowser1.Navigate "About:Blank"
WebBrowser1.Document.write strPage
 
 Set oDoc = WebBrowser1.Document
 Set oTest = oDoc.getElementsByName("btn1").Item("btn1")
End Sub


Private Function oTest_onclick() As Boolean
   Debug.Print "Click!!!!"
End Function

do i have to do an
Set oTest = oDoc.getElementsByName("btn1").Item("btn1")

for every element?

or are there better ways of doing this?



!---! if you think this belongs in a new question, pls say so and i will finalize this Q !---!
0
 
LVL 2

Expert Comment

by:daniel_j_c
Comment Utility
yeah - you'd have to hook every control you wanted to know something about (ie. capture events for). defining all of these in your form would be really ugly - your best bet would be to make a class that wraps an htmlobject and calls a function in your form thereby unifying the callbacks. something like this:

public sub ControlEvent(oControl as object, evtEvent as MyEventEnum)

so no matter what the control or event, you only have one sub through which you'll process those events. then you'd do a select case on the control type or control name, etc.

your wrapper class would have something like this:

dim withevents oInputEl as htmlinputelement
dim withevents oButton as htmlcontrol 'don't know what this would be but for buttons, etc
dim moCallback as form

public sub WrapControl(oControl, frmNotify as form)
  select case typename(ocontrol)
  case "htmlinputelement": set oinputel = ocontrol
  case "htmlcontrol":  set obutton = ocontrol
, etc
 end select

  set mocallback = frmNotify

end sub

then when you get an event:

moCallback.ControlEvent(oInputEl, Evt_Click)

hope you get the idea - that's all a bit ugly but i don't feel like typing the whole lot out and getting it working!
0
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 185 total points
Comment Utility
you can just use odoc

ie

Option Explicit
Const strPage As String = "<head><style type=""text/css"">.TestBtn {font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF;background-color: #333333;border: 1px solid #FF0000;}</style>" & vbCrLf & _
"</head><body><input name=""btn1"" type=""button"" class=""TestBtn"" value=""Test1""><input name=""btn2"" type=""button"" class=""TestBtn2"" value=""Test2""></body>"

Dim WithEvents oDoc As HTMLDocument
Private Sub Form_Load()
WebBrowser1.navigate "About:Blank"
WebBrowser1.document.write strPage
 
 Set oDoc = WebBrowser1.document
End Sub


Private Function oDoc_onclick() As Boolean
Debug.Print oDoc.activeElement.className
Debug.Print oDoc.activeElement.defaultValue
End Function


0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

that works great, except for one thing:

try clicking on the "main" document

it gives an error
this can be done with on error resume next,
but is there a better way?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
not all the object supports defaultvalue

use on error resume next is the best way
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

thank you all for your great help on this!

i was thinking about a split like this:

lojk   130
EDDYKT 185
daniel_j_c 185

everyone ok with that?
0
 
LVL 2

Expert Comment

by:daniel_j_c
Comment Utility
@EDDYKT  - good point - i was being stupid. just using odoc will save a lot of trouble.,

@Mark_FreeSoftware - you could just do this:

select case lcase(typename(odoc.activeelement))
case "htmlinputelement"
  ...
end select

because you'll know which properties, etc are supported for each element
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

that's a good idea!


>>because you'll know which properties, etc are supported for each element
actually, i don't
but i find out soon enough ;)
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
nice... there's something,rather intersting, that ive never tried to do before (probably never do it either) but useful to know none the less...

One question... Why capture page element events like this when you can do it either as asp/asp.net or straight as buttons on a rich client form? What's the benefit/point of all that extra effort?

0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility
>>or straight as buttons on a rich client form?

what do you mean?


and why i do it this way,

i'm comfortable with coding in vb,
but it is sometimes very difficult to design a nice interface

with html, you can't do great coding, just nice interface

combine them both, and you have the comfort of vb coding, and the nice interface from html!
0
 
LVL 2

Expert Comment

by:daniel_j_c
Comment Utility
another nice thing is that your interface is essentially uncompiled - ie. html. so you deploy your software and if the client wants to add a field or something, you add the field to the db and change the html interface. your code is compiled so it's protected but the user interface and db are modifiable without having to recompile - big advantage.
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
Comment Utility

and you can easily modify the interface with "skins"

simply replacing the css!
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
by Rich Client i just mean 'Standard executable' - A Client Application that has all functionality available to the platform on which it executes (unlike a webpage)

Classic ASP is quite 'Fat 'n' Ugly', but ASP.net (especially 2.0) is slick and extremely effective and provides most of the functionality that Daniel_j mentions  but has the benefits of being able to create web pages, like forms and use CSS if desired. Both are easily editable via text editors or remote full blown IDE if required.

I know we are talking more about Client Side applications that display an HTML page as its interface here than the benefits offered by ASP Server Side Coding and i think you guys are talking more about VB6 development, whereas i am very much in the .NET world nowadays. Even so in VB6 i did a lot of work with usercontrols that provided a far more encapulated approach to interface design and skinning.

All things said however, i do get what you are all saying even if, like i mentioned before, I'll never(never say never) use it.

Insert Standard 'Theres always more than one way to do XXX' line here...

Cheers for the Insight - and the Points...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now