View previous topic :: View next topic |
Author |
Message |
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Wed Mar 09, 2005 8:00 am Post subject: ActiveX support |
|
|
A couple of things: first, I'd like to know if it should be considered. Note that it wouldn't be difficult for the programmer to "version it out", so to speak, because Walnut right now has System.OSname() so you can just say:
Code: |
if (System.OSname().find("Windows") != -1)
{ ... do ActiveX ... }
else
{ ... do nothing or throw an exception or whatever ... }
|
And also, whoever wants to do ActiveX wouldn't think about their code running on a different operating system. But (like I already said) I still want to keep Walnut as platform independent as possible, so that might be worth considering.
The other issue in hand is how to do it. As far as I understand, you should be able to do something like this (forgive if the names are wrong):
Code: |
var foo = new ActiveXObject("InternetExplorer")
foo.go("www.google.com")
foo.display = true
foo = new ActiveXObject("MicrosoftWord")
foo.open("manual.doc")
|
And it'd have to just work. The question is how. The code I've seen loads COM objects using GUIDs not names, and they also declare interfaces, but obviously some kind of dynamic call is needed (if only because it's ridiculous if not impossible to have every COM interface declared).
Any ideas will be greatly appreciated. |
|
Back to top |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Fri Mar 11, 2005 12:46 pm Post subject: Re: ActiveX support |
|
|
Carlos wrote: |
And it'd have to just work. The question is how. The code I've seen loads COM objects using GUIDs not names, and they also declare interfaces, but obviously some kind of dynamic call is needed (if only because it's ridiculous if not impossible to have every COM interface declared).
|
AFAIK COM has really nothing to do with dynamically getting classes and stuff. It's more of a mechanism to connect otherwise incompatible languages. Thus a scripting language would need to declare the interfaces to be exposed in the innards. For languages written in C, like Python, this isn't a big problem as all of the Windows COM interfaces already exist as C and C++ interfaces. To use it in D, you would need the D version of these interfaces. I think.
Just a couple of cents.
I would be very interested in such functionality, btw, although I'm not sure that I'll come to the point were I really need it. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Fri Mar 11, 2005 4:34 pm Post subject: Re: ActiveX support |
|
|
larsivi wrote: | AFAIK COM has really nothing to do with dynamically getting classes and stuff. It's more of a mechanism to connect otherwise incompatible languages. Thus a scripting language would need to declare the interfaces to be exposed in the innards. For languages written in C, like Python, this isn't a big problem as all of the Windows COM interfaces already exist as C and C++ interfaces. To use it in D, you would need the D version of these interfaces. I think. |
I guess it's ActiveX, then.
larsivi wrote: | Just a couple of cents. |
Everything is appreciated.
larsivi wrote: | I would be very interested in such functionality, btw, although I'm not sure that I'll come to the point were I really need it. |
It isn't coming too hard. Considering I have zero previous experience with that, and all the research I've had to do (it ain't working fully yet, but I'm getting there), it's been good. So, I think it'll be in. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Fri Mar 11, 2005 10:09 pm Post subject: |
|
|
Carlos Santander B. (digitalmars.D:19278) wrote: |
PROPERTYGET and PROPERTYPUT work. PROPERTYPUTREF, I don't know, because I haven't tried and I don't know how to try. METHOD without parameters also works. With parameters, however, it's not as good.
So far, this code works (adapted from Justin's code in http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/18805, I hope the URL is ok):
Code: |
AXO ie=new AXO("InternetExplorer.Application");
try
{
VARIANTARG a1, a2, a3, a4;
a1.n1.n2.vt=20;
a2.n1.n2.vt=6008;
a3.n1.n2.vt=0;
a4.n1.n2.vt=17;
VARIANTARG myArg;
myArg.n1.n2.vt = VT_BSTR;
myArg.n1.n2.n3.bstrVal = "about:blank";
ie.call("Navigate",a4,a3,a2,a1,myArg);
myArg.n1.n2.vt = VT_UI4;
myArg.n1.n2.n3.lVal = 850;
ie.set("Width",myArg);
myArg.n1.n2.n3.lVal = 710;
ie.set("Height",myArg);
myArg.n1.n2.n3.lVal = 10;
ie.set("Top",myArg);
myArg.n1.n2.n3.lVal = 10;
ie.set("Left",myArg);
myArg.n1.n2.vt = VT_BOOL;
myArg.n1.n2.n3.boolVal = 0;
ie.set("ToolBar",myArg);
ie.set("MenuBar",myArg);
ie.set("StatusBar",myArg);
myArg.n1.n2.n3.boolVal = 1;
ie.set("Visible",myArg);
VARIANT tmp = ie.get("Visible");
bool isVisible = cast(bool) tmp.n1.n2.n3.boolVal;
}
finally
ie.call("Quit");
|
Works, except for the Navigate call. Going through the parameters I found their VARTYPEs, so that's why I set them, but I have no idea what they should receive. Also, I'm aware some methods are optional (Navigate has 4, I assume the only required is the URL), but only passing one doesn't work either.
So, again, some help would be nice.
|
Following that early success, this works in an internal version of Walnut:
Code: |
var ie=new ActiveXObject("InternetExplorer.Application")
ie.Visible(true)
println(ie.Visible()) //prints "true"!!!
ie.Quit()
|
Conversion from/to VARIANTs will be a royal pain (DMDScript only knows about "numbers", but VARIANTs can be int, uint, short, ushort, float, etc. How can I tell them apart?), but I'll think of something. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Fri Mar 11, 2005 11:42 pm Post subject: |
|
|
Nice going, Carlos!
I know diddley-squat about this area of COM, so I'm no use to you whatsoever. I will point out though, that the process of hooking D libraries up to Walnut would be quite dramatically simplified were D to support reflection. This might be a valid angle to get some help from Walter?
If there were a tool like Swig4D, for D libraries instead of C libraries, that might also help to hook things up.
- Kris |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|