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 / .NET Framework / New Users / May 2008

Tip: Looking for answers? Try searching our database.

Handle of running application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 19 May 2008 21:45 GMT
Hello everyone,

I have a windows application that starts Internet Explorer and I need to get
access to this page. Ideally I would like to have the document loaded into a
WebBrowser control. Also I would like to close IE after I'm finished.

What are the ingredients needed?

-james
Family Tree Mike - 20 May 2008 12:17 GMT
All you should need to do is set WebBrowser.Url = "http://somesite.com/", or
whatever the url that the application opens.

> Hello everyone,
>
[quoted text clipped - 5 lines]
>
> -james
James - 20 May 2008 14:12 GMT
Thanks Mike,

I do that at first but the website opens a new page with the info I want.

I have read an article from the book called 'Visual Basic 2005 Cookbook'
that uses the System.Diagnostics.Process.GetProcesses. Now I have the handle
to IE but now what? Hmmm? To bad a the webmaster starts a new IE!!!

This code is from the book.

       For Each oneProcess As System.Diagnostics.Process In
System.Diagnostics.Process.GetProcesses
           If oneProcess.MainWindowTitle.Contains("Bus Stop Schedule") Then
               MessageBox.Show(oneProcess.MainWindowTitle)
           End If
       Next

> All you should need to do is set WebBrowser.Url = "http://somesite.com/",
> or
[quoted text clipped - 11 lines]
>>
>> -james
Family Tree Mike - 20 May 2008 16:41 GMT
So are you saying that the page in the webcontrol is redirected to a new IE
window, or that the webcontrol contains a redirected page?  If it is the
latter, then you can handle the Navigated or Navigating events to see where
the new URL is pointing.

> Thanks Mike,
>
[quoted text clipped - 28 lines]
> >>
> >> -james
James - 20 May 2008 18:01 GMT
Hey Mike,
I load the web page into a web control. When I change some textboxes/inputs
I then execute the onclick for the form using InvokeMember. This runs but
the reply comes up in IE not the web control. The web master does this for
all such forms!!! Arg!

If there is a better way please let me know! Sure wish they used Web
Services though!!!

However, I have found a solution, see http://support.microsoft.com/kb/176792
For the people who are interested I included my code (below) as this method
is not that friendly.

My webcontrol loads this page.
http://www.edmonton.ca/portal/server.pt?open=space&name=CommunityPage&id=cached&
psname=CommunityPage&psid=0&in_hi_userid=2&cached=true&control=SetCommunity&Comm
unityID=218&PageID=0


In the top right corner of this page you will see "Today's Bus Stop
Schedule". Using a webcontrol I fill in the bus stop, (eg. 1468), as needed
and run the onclick. On the reply page the code below will ferret out the
info I need. If your interested use bus stop id 1468.

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
       '
       ' ShDocVw & msHTML dll's
       ' You have to add these two dll's.
       ' They are found in the \windows\system32 folder
       ' To add shdocvw you may have to add the shdocvw.tlb - tells VS
how/what to add
       '
       ' Variables IE an SWs are globally declared (msHTML, ShDocVw
respectively)

       ' Info from web page reply i need
       Dim bsTime As String
       Dim bsRoute As String

       For Each IE In SWs

           'locate my reply page
           If IE.LocationName.Contains("Bus Stop Schedule") Then

               'must have a mshtml.htmldocument to access GetElementById
               'Note cannot cType to system.windows.forms.htmldocument :(
               Dim IEDoc As mshtml.HTMLDocument = IE.Document

               'Get an htmlelement
               'note cannot convert to an htmlelement so object is used
               Dim elementGetItem As Object =
IEDoc.getElementById("dgdBusSchedule__ctl1_lblDepartureDate")

               'elementGetItem is in fact an htmlelement so I can use it as
such - no intellisence :(
               bsTime = elementGetItem.innertext

               elementGetItem =
IEDoc.getElementById("dgdBusSchedule__ctl1_lnkRouteNumber")
               bsRoute = elementGetItem.innertext

               MessageBox.Show("Next bus @: " & bsTime, "Bus Route: " &
bsRoute)

               Exit For
           End If

       Next

   End Sub

> So are you saying that the page in the webcontrol is redirected to a new
> IE
[quoted text clipped - 39 lines]
>> >>
>> >> -james
Jeff Winn - 22 May 2008 21:33 GMT
Are you trying to read the information off the page and display it in your
application? Sounds like you're trying to parse the page if you were wanting
to hook to a web service. If so, just use the HttpWebRequest and
HttpWebResponse classes and do the POST yourself. Get the data returned from
the response and stick it into a viewer on your app somewhere, or parse the
data out of the page.

> Hey Mike,
> I load the web page into a web control. When I change some
[quoted text clipped - 110 lines]
>>> >>
>>> >> -james
James - 23 May 2008 02:46 GMT
Thanks Jeff,
I will look into your suggestion.

The transit web site will not load the reply page, it always crashes (on my
htc touch) . It is a really handy site, but you have to be at a computer. If
it worked on my htc touch, it would be much better I deem. So I created a
little server that accepts and delivers the info I need - quite neat in
fact. I always know when the next bus is no matter where or what I'm doing.

The draw back is the page pops up and then closes - not elegant but it works
without error! Having more then one system I don't care too much.

Thanks for your suggestion, I will endeavor to get familiar with
HttpWebRequest  and HttpWebResponse.

-James

> Are you trying to read the information off the page and display it in your
> application? Sounds like you're trying to parse the page if you were
[quoted text clipped - 120 lines]
>>>> >>
>>>> >> -james
James - 27 May 2008 15:08 GMT
Hi Jeff,
I was doing some research into using HttpWebRequest  & HttpWebResponse. The
application I have is too complex for using this method. I can get my first
page all good, and even populate a WebBrowser control. What cannot be done
is run the apropriate onclick (Button). Using POST and SUBMIT generates
errors from the server. Once again I shake my finger at this
webmaster/programmer (naughty,naughty). It could be worse, she could make
small changes frequently (fingers now crossed). Wish they would use
web-services!

If the first page had the info I needed, or was just a straight forward
POST|SUBMIT this would be ace.

Also, HttpWebRequest and HttpWebResponse are considered Obsolete - so I was
using WebRequest and WebResponse - which are the same more or less.

-James

> Thanks Jeff,
> I will look into your suggestion.
[quoted text clipped - 140 lines]
>>>>> >>
>>>>> >> -james

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.