Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

working with IHTMLDocument and friends

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 18 Jun 2004 14:52 GMT
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
Charles Law - 18 Jun 2004 15:25 GMT
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

> Hi, I need to get the following VB6 code to work in .NET:
> '/////
[quoted text clipped - 24 lines]
>
> Chris
Nick Malik - 19 Jun 2004 04:49 GMT
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

> Hi, I need to get the following VB6 code to work in .NET:
> '/////
[quoted text clipped - 24 lines]
>
> Chris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.