473,725 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to a running instance of an embedded webBrowser control

Hi,

ok, I found a way to connect to a running instance of an (external) Internet
Explorer and access - for example - the html source. That works fine!

But now I have running application with an embedded IE webBrowser Control.
Is there a possibility for my application to access the webBrowser control in
the other application, too?

Thanks in advance, Randy

Nov 17 '05 #1
4 2885
Use remoting. In otherwords, expose your Form (which is MarshalByRefObj ect) over a TCP remoting channel and consume it in any other
..NET application by using client remoting. Make a public property for access to the browser control.

public AxWebBrowser Browser { get { return browserCtrl; } }

public TheForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(1024);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

System.Runtime. Remoting.Remoti ngServices.Conn ect(typeof(TheF orm),
"tcp://localhost/theform:1024");
}

To consume the form, your project must have a reference to the assembly which contains TheForm:

public AXWebBrowser GetBrowserFromR emotingForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(0);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

TheForm form = Activator.GetOb ject(typeof(The Form), "tcp://localhost/theform:1024");
return form.WebBrowser ;
}
I didn't test the code, so it will probably require some mods. Also, realize that when remoting an object such as a Form, all
properties must be serializable in some fashion, whether through declaration or inheritance. In this case it might make more sense
to remote an object to act as a proxy for the Form class that can return the WebBrowser control.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Randy" <Ra***@discussi ons.microsoft.c om> wrote in message news:33******** *************** ***********@mic rosoft.com...
Hi,

ok, I found a way to connect to a running instance of an (external) Internet
Explorer and access - for example - the html source. That works fine!

But now I have running application with an embedded IE webBrowser Control.
Is there a possibility for my application to access the webBrowser control in
the other application, too?

Thanks in advance, Randy

Nov 17 '05 #2
Hi Dave,

thanks for your reply. Unfortunately the program with the embedded
webbrowser control is a "finished" application from another company (and I
don't have a chance to modify the source ;-)).

Is there a possibility to connect to the webbrowser control inside anyway
(to get the HTM Source)?

Thanks, Randy

"Dave" wrote:
Use remoting. In otherwords, expose your Form (which is MarshalByRefObj ect) over a TCP remoting channel and consume it in any other
..NET application by using client remoting. Make a public property for access to the browser control.

public AxWebBrowser Browser { get { return browserCtrl; } }

public TheForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(1024);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

System.Runtime. Remoting.Remoti ngServices.Conn ect(typeof(TheF orm),
"tcp://localhost/theform:1024");
}

To consume the form, your project must have a reference to the assembly which contains TheForm:

public AXWebBrowser GetBrowserFromR emotingForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(0);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

TheForm form = Activator.GetOb ject(typeof(The Form), "tcp://localhost/theform:1024");
return form.WebBrowser ;
}
I didn't test the code, so it will probably require some mods. Also, realize that when remoting an object such as a Form, all
properties must be serializable in some fashion, whether through declaration or inheritance. In this case it might make more sense
to remote an object to act as a proxy for the Form class that can return the WebBrowser control.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Randy" <Ra***@discussi ons.microsoft.c om> wrote in message news:33******** *************** ***********@mic rosoft.com...
Hi,

ok, I found a way to connect to a running instance of an (external) Internet
Explorer and access - for example - the html source. That works fine!

But now I have running application with an embedded IE webBrowser Control.
Is there a possibility for my application to access the webBrowser control in
the other application, too?

Thanks in advance, Randy


Nov 17 '05 #3
Yes, there still is another solution: Interop.

Open Spy++ if you have it, and get the classname for the window you are after (the browser itself)

There are Win32 functions that allow code to access other processes, the main window, child windows, etc..

A function called FindWindowEx may be what your after:

http://msdn.microsoft.com/library/de...ndwindowex.asp

[DllImport("user 32.dll")]
private static extern IntPtr FindWindowEx(In tPtr parent, IntPtr childAfter, string className, string windowName);

You can specify the MainWindowHandl e (which can be obtained via System.Diagnost ics.Process) of the process containing the embedded
web browser as the "parent" parameter. childAfter may be IntPtr.Zero in your circumstance, but read the docs to find out.
className should be that of the WebBrowser control (that you obtained via Spy++), and windowName can be specified as null.

------------------------------------------------------------------------
I'm not sure how to get an IUnknown pointer from just a window handle, but I assume it' possible. If so, a bit of research will get
you there. Maybe somebody will be nice enough to post a solution for you...
------------------------------------------------------------------------

If you get the IUnknown pointer, you can use the following line of code to get an interface for the browser:

SHDocVw.IWebBro wser2 browser =
System.Runtime. InteropServices .Marshal.GetTyp edObjectForIUnk nown(pUnk, typeof(SHDocVw. IWebBrowser2));

At this point, you can use your existing code to access the HTML.
GL :)

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Randy" <Ra***@discussi ons.microsoft.c om> wrote in message news:16******** *************** ***********@mic rosoft.com...
Hi Dave,

thanks for your reply. Unfortunately the program with the embedded
webbrowser control is a "finished" application from another company (and I
don't have a chance to modify the source ;-)).

Is there a possibility to connect to the webbrowser control inside anyway
(to get the HTM Source)?

Thanks, Randy

"Dave" wrote:
Use remoting. In otherwords, expose your Form (which is MarshalByRefObj ect) over a TCP remoting channel and consume it in any
other
..NET application by using client remoting. Make a public property for access to the browser control.

public AxWebBrowser Browser { get { return browserCtrl; } }

public TheForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(1024);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

System.Runtime. Remoting.Remoti ngServices.Conn ect(typeof(TheF orm),
"tcp://localhost/theform:1024");
}

To consume the form, your project must have a reference to the assembly which contains TheForm:

public AXWebBrowser GetBrowserFromR emotingForm()
{
System.Runtime. Remoting.Channe ls.Tcp.TcpChann el channel =
new System.Runtime. Remoting.Channe ls.Tcp.TcpChann el(0);

System.Runtime. Remoting.Channe ls.ChannelServi ces.RegisterCha nnel(channel);

TheForm form = Activator.GetOb ject(typeof(The Form), "tcp://localhost/theform:1024");
return form.WebBrowser ;
}
I didn't test the code, so it will probably require some mods. Also, realize that when remoting an object such as a Form, all
properties must be serializable in some fashion, whether through declaration or inheritance. In this case it might make more
sense
to remote an object to act as a proxy for the Form class that can return the WebBrowser control.

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Randy" <Ra***@discussi ons.microsoft.c om> wrote in message news:33******** *************** ***********@mic rosoft.com...
> Hi,
>
> ok, I found a way to connect to a running instance of an (external) Internet
> Explorer and access - for example - the html source. That works fine!
>
> But now I have running application with an embedded IE webBrowser Control.
> Is there a possibility for my application to access the webBrowser control in
> the other application, too?
>
> Thanks in advance, Randy
>


Nov 17 '05 #4
Hi Dave,

thanks a lot again....now all is much clearer for me...

------------------------------------------------------------------------
I'm not sure how to get an IUnknown pointer from just a window handle, but I assume it' possible. If so, a bit of research will get
you there. Maybe somebody will be nice enough to post a solution for you...
------------------------------------------------------------------------


unfortunately I could't find anything in the www that solves the problem
above... Could anybody help me? or does anybody know a complete script that
shows the way to solve the described problem?

Thanks a lot,

Randy
Nov 17 '05 #5

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

Similar topics

1
7985
by: Vetrivel | last post by:
Application architecture : Develop interface between two existing systems, a. Enterprise CRM system b. Web based intranet system. Environment : Intranet Server : IIS and ASP. Script : VBScript and Javascript Client : 1. IE browser. 2. VBForm embedded with WebBrowser control (MS Internet
10
1720
by: ej1008 | last post by:
HI all I am having a windows Control running on ASP.Net webform. From this windows control I am trying to connect to database to do some database operations. Now I am facing problem while connecting to Database from client systems which is having only .net framework without SQL Client Installed. It works fine on client systems having .Net Installed with SQL Client What could be the problem. How Can I resolve this problem? I am sure...
1
3301
by: L. Chernov | last post by:
Hello, I am trying to work with .Net 2005 WebBrowser object, and put it on a "Windows control library" (embedded in a user control class) and then I am executing it from an ASP.Net webform(with IE6) with the following object tag: <OBJECT id="ModPkiObj" height="550" width="800" classid="http:ModPkiNew.dll#Mod.Online.Client.ModPkiNew.SignForm" name="ModPkiObj" VIEWASTEXT>
2
7390
by: FishingScout | last post by:
I have a small html file that I have added to my project. When I added "sample.html", I set the build action to "embedded resource". In the application I would like to do something like this ( but this doesn't work ): WebBrowser.Navigate( "MyApplication.Sample.html" ) Does anyone know if
5
2068
by: jeremy | last post by:
I have an ASP.Net 2.0 application running on Windows Server 2003. The application displays properly in Internet Explorer, however, when I use a browser control embedded in a .net form, I get an error and am directed to the Windows Application Event Log. The following message is logged: ------------- Source: ASP.NET 1.1.4322.0 Event ID: 1062
5
6581
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same (System.Runtime.InteropServices.Marshal.ReleaseComObject(exApplication)) to solve my problem but could not. Background : My app uses a WebBrowser control to display to the user the contents of an Excel spreadsheet.:
0
2005
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
2
1157
by: Anil Gupe/keen inc. | last post by:
I have an embedded browser in which the user does some stuff (PayPal payment actually). When done, I redirect to a page that contains the following JavaScript <tr vAlign="top"> <td>&nbsp;</td> <td<a href="javascript: self.close ()">Close this Window</a></td> <td>&nbsp;</td> </tr>
2
3632
by: Federico Cozzi | last post by:
Hello, in my VB.net I would like to 1) start a new Internet Explorer process (not a new window of the running process) 2) and connecting to its WebBrowser control, or InternetExplorerClass, afterwards. Basically, creating a new WebBrowser doesn't work because it opens a new window of the running Internet Explorer, but if I start a new IE process (with System.Diagnostics.etc..) I don't know how to use it "as
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.