|
Thanks Heath on your reply .
Basically I need to get the value of hyperlink on cursor like in web browser when we Hover the hyperlink, it showing hyperlink value in status bar.so the value which shows in status bar i need to get these values. please give me the solution in dotnet (C#)
|
|
|
|
|
I did give you a solution using C#, but it requires you to interop with COM. The solution gets the actual value of the A.href attribute. If you want an absolute URL, combine the IHTMLDocument2.location.href (casting AxWebBrowser2.Document to IHTMLDocument2 this time - this is just how COM interop and COM itself works) and the link value from the first solution:
IHTMLDocument2 doc2 = (IHTMLDocument2)axWebBrowser2.Document;
if (doc != null)
{
Uri url = new Uri(doc2.location.href);
url = new Uri(url, a.href);
} Now you've got an absolute URL. To be 100% correct, however, you should retrieve the IHTMLBaseElement from the <HEAD> and gets it's href attribute value - if any. This is an optional element so it may not exist; if it does exist it re-scopes URLs contained within the document to be relative to the <BASE href> value.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
...and for more information about COM interoperability to help you walk the DOM using the WebBrowser control, read Exposing COM Components to the .NET Framework[^] in the .NET Framework SDK.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you Heath for your prompt replies and usefull guidance...can you tell me what i should to make my browser to take the value of links when ever my mouse hovers it...because i have tried the way you have told but it is not picking the url of that link.
|
|
|
|
|
You need to handle the IHTMLDocument2.body 's onmouseover event in order to get the current element under the mouse. Copy the code snippet and see how it works in the browser. Everything JScript can do your application can do because they use the same automation server - the WebBrowser control or MSHTML (which is hosted by the WebBrowser control):
<html>
<head>
<title>Test</title>
</head>
<body onmouseover="showCurrentElement(event)">
<p>This is a paragraph of text with a <a href="http://www.microsoft.com">hyperlink</a> embedded.</p>
<p><b>Look at me - I'm bold!</b></p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p id="currentElement"></p>
</body>
<script type="text/jscript">
function showCurrentElement(e)
{
var lbl = document.getElementById("currentElement");
if (lbl)
{
lbl.innerText = e.srcElement.tagName;
}
}
</script>
</html> You really need to read the links I gave you regarding COM interop. There's also several articles on this site about programming with the WebBrowser control, as well as on MSDN[^]. There's a lot to understand, but it's not difficult especially if you understand COM.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
you mean that i should add this code snippet in my C# program?
|
|
|
|
|
No, you should do something like the HTML - which is what I said in my previous post - and handle the IHTMLDocument2.body.onmouseover event like you would any other event. You get the srcElement (the element that fired the event) from the IHTMLEventObj .
The HTML was - again - an example of what you need to do. I've given you plenty of samples and you can find more by clicking "Search comments" to search this message board (and others, if you like) or use the search box at the top of every page to search for articles.
If you read the documentation I've linked for you all this will make a lot more sense.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank You so much Heath....you have solved my problem.
|
|
|
|
|
Ok here goes, if i can get a program to compile and work in the windows version of mono...then is it possible for the program to run in linux and windows...if not will the code compile ok in linux then.
|
|
|
|
|
If you can get it compile under Mono using the Mono C# compiler, in theory and mostly in practice, your application will then run on both Windows and Linux. I say in theory only because, as is the case with Java, there are some caveats; certain features may work slightly differently on some different platforms.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
|
Mono is another implementation of the Common Language Infrastructure (CLI), of which .NET is Microsoft's implementation. The CLI states that certain things must be implemented and Windows Forms, for example, is not one of them. So long as you classes defined in ECMA-certified base class libraries (like those assemblies of the .NET BCL having the publicKeyToken value b77a5c561934e089) it should work.
Mono and .NET have different ways of implementing Windows Forms, however. The .NET BCLs P/Invoke native Windows APIs and handle messages since they encapsulate the Windows Common Controls. Certain implementations of Mono use the QT or GTK toolkits. This is where things really different.
Also keep in mind that .NET compilers (that is, language compilers for the .NET Framework) wrap IL modules in a PE/COFF executable but Mono can handle this.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thx for info...Looks like porting my program is gonna be a learning experience.
|
|
|
|
|
|
Hi all,
How to communicate between an application and a windows service on the same machine.
Here I want to access data generated by service and process it through an application(UI) and then, send some data from the application to the service to add it in the log.
Thanks..
|
|
|
|
|
The best way is whatever inter-process communication (IPC) protocol works best for you. If both executables are managed, then I recommend .NET Remoting[^]. The remoting infrastructure loosly defines the transport and formatting layers for IPC and is built on and for managed code. It isn't a straight-forward infrastructure, however, so I do recommend picking up a book on it depending on what you need to do (the move advanced objects you require to communicate, the more you should invest a an inexpensive book).
You could also P/Invoke RPC functions, but to do so would require you building an infrastructure similar to .NET Remoting.
With .NET Remoting you should use a TcpChannel in this case (lower overhead; .NET 2.0 will introduce named pipes for a channel for faster transport) but you could always use a TcpClient and TcpListener with your own protocol for marshaling (serializing and transporting) objects.
The sky is the limit on this one.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have created several layers of dialog boxes using MFC C++ .Net. However, I do not want to automatically go back to calling dialog when I hit return anywhere in the active dialog. I want to just be able to click on OK button to do this.
I have the OK button as not the Default button, but clicking anywhere in Dialog box always closes the active Dialog Box and goes back to calling Dialog box. Is there a fix?
|
|
|
|
|
This forum is for C# questions. Ask again in the Managed C++ forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Will very much appreciate if someone pointed me to a Wintab32 library class in c sharp
|
|
|
|
|
|
In VB6, you can do the following:
foreach control in form
//do stuff to each
next
In c#, you have to add an identifier to use the foreach with the array or collection.
I want to loop through a group of controls (like radiobuttons, etc.)
i.e. foreach (RadioButton in form1) {//do code}
Obviously, this code will not work, but does anyone know how this can be done in C# ? I would appreciate the help.
Thanks in advance.
|
|
|
|
|
Just declare a variable for RadioButton inside foreach like this
foreach(RadioButton radioButton in form1) {//do code}
|
|
|
|
|
This will only work if there are only RadioButtons on the form.
I would try the following:
foreach (Control control in form1) {
RadioButton rb = control as RadioButton;
if (rb != null) {
}
}
|
|
|
|
|
That option will work (going through each control, then doing an if-statement. Another option would be to write your own iterator that returns an IEnumerable list of radio buttons.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
OK... I admit to being a newbi (one that WANTS to learn), but something is not working.
I cannot use the foreach because of the following:
" foreach statement cannot operate on variables of type 'System.Windows.Forms.GroupBox' because 'System.Windows.Forms.GroupBox' does not contain a definition for 'GetEnumerator', or it is inaccessible
I tried it in a usercontrol as well with the same error.
Do I need to make the groupbox IEnumerable? I am not sure about "write your own iterator that returns an IEnumerable list of radio buttons". Sounds like fun... Could you let me know what is involved?
THanks
|
|
|
|