|
Hello again,
My earlier post got results related to invoking a script within the context of a page. This is interesting but not what I was looking to do. The execScript() method referred to lets you pass in a script string and have it executed.
I need to invoke a script that is part of the downloaded page after it loads. An example script would be signalling a custom event. Can anyone out there help?
Thanks in advance and Happy Thanksgiving!
|
|
|
|
|
Me think the necesssary tool is already provided.
execScript(scriptcode) allows to execute arbitrary javascript code, so if we assume that the function you are willing to call from the web page is called myfunction() , why wouldn't you do just that :
execScript("<script>myfunction();</script>");
RSS feed
|
|
|
|
|
If this worked for me I'd be psyched. I've tried it and the code in NavigateComplete does not find the methods on the page. Odd thing is, I can set a variable value from the NavigateComplete method with code like:
scriptStr = "var scriptVal = \"this is the C sharp value\";";
try
{
Object retVal = iwnd.execScript(scriptStr, "JScript");
}
catch (Exception ex)
{
Console.WriteLine("SCRIPT EXC: " + ex.Message);
}
// The following is a snippet of script from a web page that displays the
// value of "scriptVal" that was set from the C# code in NavigateComplete.
var scriptVal;
alert("ScriptVal == " + scriptVal);
The "alert" in the html page displays the string value set with the execScript method. I've tried:
- changing the script language in the execScript method to "null"
(Object retVal = iwnd.execScript(scriptStr, null);) and this works.
- bracketed the script passed to execScript with the open/close script tags and this does NOT work.
- passed in the name of a valid script method to the execScript method and this does NOT work.
- bracketed the method with open/close script tags, passed it to the execScript method and this did NOT work.
(the prior two with explicitly specifying language in execScript and that did NOT work either)
I know I'm close to a solution here but I'm missing something fundamental.
Do I need to get the ScriptControl somehow and use the methods in there to solve this?
Thanks
|
|
|
|
|
Hiya I have a dataset filled with my data and need to write this dataset to my blank crystal report I have inserted into the project.
Because I want to then view the data in the Crystal Report Viewer.
How do I do this??
Thanks.
|
|
|
|
|
Try this. It might help! good luck!
http://www.tek-tips.com/gfaqs.cfm/pid/796/fid/3940
knvsolutions
|
|
|
|
|
Hey
I am about to make a Simple 2D game with tanks. A game where you will drive you tank around on a map an shoot on other tanks(simple).
I are thinking of using the regular Direct X, and have started to learn this, but i heard somthing about DirectX managed, and that sounds simple.
But what shold i go with ?
and if i shold go with DirectX manged is there any beginning turtotials on this subject?
Best regards
Jimmy
PS sorry for the bad english
|
|
|
|
|
|
Please look at the sample code in this[^] MSDN page for the ControlBindingsCollection.Add method.
What is the purpose of binding those rows to the control? How is that useful? Which of the 3 rows does it bind to? I guess I just don't understand the purpose of that code. Please enlighten me!
Thanks in advance,
Alvaro
He who laughs last, thinks slowest.
|
|
|
|
|
The example binds various fields in a DataTable to properties of a control. Initially, the control is bound to the first row. When the Position is changed in a CurrencyManager (which you can get from the BindingContext of a control), the properties of that control then use properties of the row pointed to by the Position property. You should also look up information on the BindingContext property for controls for more details and sample code.
If you've used Microsoft Access, think of a Form bound to a result set and with the navigation bar visible. When you click the navigation buttons, the Form's controls are bound to the data for the current result.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for clearing it up Heath. I should have seen the BindingContext property.
I looked up CurrencyManager in MSDN and the example they have there[^] shows what you're talking about.
Regards,
Alvaro
He who laughs last, thinks slowest.
|
|
|
|
|
Hello people,
How can I load the control (like Button) in designMode on my form. It's meen that the control will be painted and proceeded by it own designer.
regards,
OPopov
|
|
|
|
|
The control must still handle it's own painting, otherwise it wouldn't even show up (or redraw itself when necessary) at runtime. You can use the ControlDesigner that you would create to paint adornments (like grips) on the control, though. Painting is just part of any UI control.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
VS.NET IDE using designers to proceed controls painting and message handling at design-time. So we can see designers own paint on the IDE Design page (IMHO). And the problem is to emulate IDE Designer. It's meen that we can load control from assembly and show it on our own form. But we must see and touch control-designer not the control.
Regards,
OPopov
|
|
|
|
|
No, any Windows Forms .NET hosting environment still lets the control paint itself. The routines are already there and pre-empting that would be stupid. Designers can paint on top of the controls. If the designer does pre-empt the painting, it isn't exposed through the .NET framework. This is all documented in the VSHIK and you should read it if you're wanting to venture this way.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
I have built a C# based application with the Web Browser control for the UI. This was fairly straight forward. I then needed to add some of my own external methods (i.e. scripting window.external.foo()) and that was achieved by hooking in with the GetExternal method of IDocHostUIHandler thanks to the help of the article written by Ted Faison.
The last piece to the puzzle I need to solve is that I need to be able to lookup and invoke script (JScript / VBScript) methods that live within a downloaded web page. Can someone help here? I am having trouble getting access to the script control.
Thank you.
|
|
|
|
|
If you know the names of the functions you can get the IHTMLWindow2 interface of the window object and call the execScript method.
|
|
|
|
|
Thank you. I'm looking for a clean way to detect whether the script function exists before attempting to exec it also. The program needs to fail gracefully and this interface doesn't seem to give me that option.
|
|
|
|
|
Then wrap that functionality in a try-catch block and handle the exception in the catch block.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I did that initially. The problem is that you blindly invoke a script that doesn't exist and the browser catches the error. This is what I'm trying to prevent.
Thanks.
|
|
|
|
|
Then get the IHTMLDocument2 interface, get an IHTMLElementCollection from its scripts property, then enumerate the IHTMLScriptElement objects in the collection. There's various properties on said element that can help you identify what's in it. You can query the text element for a simple pattern match: "function[\s]+(\w+)".
Each match will be your function name.
The only other way that seems possible is to get the IHTMLDocument and get the IDispatch to the script engine from the Scripts property. It's not well documented what this is, but it seems evident that you could call IDispatch.GetTypeInfo , then from the ITypeInfo reference you get back (you may have to define this interface using the appropriate GUIDs and what-not yourself), call ITypeInfo.GetNames , then use the BSTR array to call IDispatch.GetIDsOfNames . Once you get those IDs, you can invoke them using IDispatch.Invoke .
All these interfaces - except for ITypeInfo - should already be defined in the Microsoft.mshtml.dll assembly. ITypeInfo shouldn't be hard to define since you only need to define the interface so that the interface GUID, interface type, and optionally DispIDs match-up to the way the native interface is defined, taking into account all out and ref keywords, as well as necessary values in the MarshalAsAttribute and OutAttribute for interop.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I would like to know of a resource that has details on available namespaces. for example in C++ I'd use iostream.h for i/o operations, but in C# I do not know what I would use (all I know are System and Collections, but no details on the functions within them).
Can anyone suggest somewhere?
Obseve everything, remember more...
|
|
|
|
|
|
Nick's advice is what I would give you, too. But I wanted to throw in some things here:
You'll also want to read articles on sites like this one and C-Sharp-Corner[^].
tom76 wrote:
in C++ I'd use iostream.h for i/o operations, but in C# I do not know what I would use
System.IO has many helpful classes for this - File and FileInfo for working with files, Directory for working with directories, Path for working with paths, and FileStream, TextWriter, TextReader, StreamReader, StreamWriter, etc for reading and writing to files.
|
|
|
|
|
Does anybody know a good HTML parser written in .net hopefully C#. I'm automating IE right now and I'm looking for something that handles real world HTML with low overhead.
|
|
|
|
|
andy brummer wrote:
I'm automating IE right now and I'm looking for something that handles real world HTML with low overhead.
So, why not use MSHTML.HTMLDocument? With this, you'll use IE's parser engine and you'll have the least overhead possible, as you'll use the very same IE that's in memory.
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|