473,378 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

working with IHTMLDocument and friends

Hi, I need to get the following VB6 code to work in .NET:
'/////
Dim doc As MSHTML.HTMLDocument
....
doc.getElementsByName("username").Item(0).Value = sn
doc.getElementsByName("password").Item(0).Value = pass
doc.getElementsByName("savepwd").Item(0).Checked = "yes"
'\\\\\

I got as far as the Item(0) part using C# and Microsoft.mshtml:
//////////////////////
HTMLDocumentClass doc = browser.Document as HTMLDocumentClass
HTMLElementCollectionClass elem =
doc.getElementsByName("username") as HTMLElementCollectionClass
object item = elem.item(0, 0);
// according to the MS documentation, item is now an IDispatch, but that
// interface exists in System.Windows.Forms.UnsafeNativeMethods, which
// is an internal class in mscorlib - not available for us to use.
//////////////////////

I'm not sure how I should proceed. Could I write a wrapper in C++ that
could use the IDispatch interface described in mshtml.h? If so, I haven't
the sleightest idea how, and google can't find anyone else who's tried this
(and succeeded).

Any help is appreciated.

Chris
Jul 21 '05 #1
2 3806
Hi Chris

What exactly is the problem? You say that you got as far as the Item(0)
part, but don't say what stopped you going further.

getElementsByName returns an IHtmlElementCollection. You can define
something like

<code>
Dim ihec As IHtmlElementCollection

ihec = DirectCast(doc.getElementsByName("username"), IHtmlElementCollection)

ihec.Item(...) etc
</code>

If username is an input element then you can add

<code>
Dim ihie As IHtmlInputElement

ihie = DirectCast(ihec.Item("username"), IHtmlInputElement)

x = ihie.Value
</code>

HTH

Charles
"Chris" <ct******@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi, I need to get the following VB6 code to work in .NET:
'/////
Dim doc As MSHTML.HTMLDocument
...
doc.getElementsByName("username").Item(0).Value = sn
doc.getElementsByName("password").Item(0).Value = pass
doc.getElementsByName("savepwd").Item(0).Checked = "yes"
'\\\\\

I got as far as the Item(0) part using C# and Microsoft.mshtml:
//////////////////////
HTMLDocumentClass doc = browser.Document as HTMLDocumentClass
HTMLElementCollectionClass elem =
doc.getElementsByName("username") as HTMLElementCollectionClass
object item = elem.item(0, 0);
// according to the MS documentation, item is now an IDispatch, but that
// interface exists in System.Windows.Forms.UnsafeNativeMethods, which
// is an internal class in mscorlib - not available for us to use.
//////////////////////

I'm not sure how I should proceed. Could I write a wrapper in C++ that
could use the IDispatch interface described in mshtml.h? If so, I haven't
the sleightest idea how, and google can't find anyone else who's tried this (and succeeded).

Any help is appreciated.

Chris

Jul 21 '05 #2
It isn't clear what you are trying to do. This code looks like you are
trying to use MSHTML to get a web page.

Instead of using a COM component, us a native .NET class. (e.g. rewrite
it). If you tell me what you are trying to do, I may be able to help you
find the correct .NET class to use in place of this.

--- Nick

"Chris" <ct******@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi, I need to get the following VB6 code to work in .NET:
'/////
Dim doc As MSHTML.HTMLDocument
...
doc.getElementsByName("username").Item(0).Value = sn
doc.getElementsByName("password").Item(0).Value = pass
doc.getElementsByName("savepwd").Item(0).Checked = "yes"
'\\\\\

I got as far as the Item(0) part using C# and Microsoft.mshtml:
//////////////////////
HTMLDocumentClass doc = browser.Document as HTMLDocumentClass
HTMLElementCollectionClass elem =
doc.getElementsByName("username") as HTMLElementCollectionClass
object item = elem.item(0, 0);
// according to the MS documentation, item is now an IDispatch, but that
// interface exists in System.Windows.Forms.UnsafeNativeMethods, which
// is an internal class in mscorlib - not available for us to use.
//////////////////////

I'm not sure how I should proceed. Could I write a wrapper in C++ that
could use the IDispatch interface described in mshtml.h? If so, I haven't
the sleightest idea how, and google can't find anyone else who's tried this (and succeeded).

Any help is appreciated.

Chris

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Henri Sivonen | last post by:
URL: http://hsivonen.iki.fi/france-2005/ On the page, markup looks like this: <p class="imgpara"><a href="..."><img src="..." alt="..." height="..." width="..."></a>Caption 1</p> <p...
6
by: (Pete Cresswell) | last post by:
I'm makeing a little DB to help manage high school class reunions. One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend of Joe Jones and Bill Anderson. We record...
1
by: Sean McKaharay | last post by:
I am having a major issue trying to print html document in landscape mode. you can us I.E. page setup when you get prompted for a printer but I don't want to prompt the user. I want to be able to...
0
by: Tchek | last post by:
Hello. Does anybody know how to get IHTMLDocument interface from webBrowser1->Document->DomDocument? As I know in C# it looks like this mshtml.IHTMLDocument2 doc2 =...
2
by: prad | last post by:
Hi, I am working with webservices in asp.net framework 2.0. when i run the webservice it didnot give any errors and it was working well but when I add it to one of my projects as add web...
31
by: ajos | last post by:
hi frnds, i have a form,which has 2 input text boxes, the values are entering the text boxes,when i leave the 2 text boxes blank and hit submit a java script gives the message that the 2 fields are...
6
by: laredotornado | last post by:
Hi, On this page http://easyrx.us/public/register/start I have a table (with the burnt orange background, to the right) within a table cell. The background color of the cell is purple,...
36
by: sheldonlg | last post by:
Here is an app: www.sheldonlg.com/JSstops.htm It passes strict W3C validation. **In IE6**, if you click on the plus, a sub-table appears. Click on the plus from the subtable and nothing...
8
by: Meri | last post by:
Hello Everybody on the internet seems to think this is a problem with IE but for me it works fine with IE, but the submenus do not appear with Firefox andOpera. The html is a simple list with...
11
by: wassimdaccache | last post by:
Dear friends I am working on access 2007 sp2. I do have a database(accdb) i converted it to accde. While I am opening the converted database the VBA code is not working. For example...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.