shadowfyr55
05-10-2006, 03:01 PM
This is probably going to generate the online equivalent of blank stares and comments like, "Why don't you just impliment blah?", but I figured I would try anyway.. lol
Situation: I "use" a client application that impliments script engine support, of multiple engines, and some callbacks for events specific to the client itself. Do to the nature of the client it is occationally useful to connect ActiveX controls into the script engine. For the most part these have all been ones with one-way interfaces, like ODBC, etc. However, it would be nice to be able to have events actually trigger one of the script functions.
Problems:
a. This seems stupidly complicated, at least to find any useful code examples for bloody doing it.
b. The one solution I have tracked down involves using ATL to bridge the controls through the client. The developer uses MFC though and is reluctant to impliment such a thing. Part of that is because he knows even lass about ATL than I do.
The actual questions:
1. When you instance an ActiveX object in a script engine "what" is the parent window for it? I personally assume that, since it needs one to work at all, that the parent will be the client that has instanced the engine, but I can't be 100% sure about that.
2. If I am right, then shouldn't the clients main event handler functions be recieving the events from such objects already? Or, in other words, if I do something like:
set a = CreateObject("VBDialog")
Won't the client itself get the "OK" or "Cancel" events from that dialogs window anyway, without having to use IConnectionPointContainer::Advise to link it directly to a function?
Frankly I think the developer is being overly paranoid about ATL possibly breaking or trying to impliment a more correct call to the ActiveX control's IUnknown to get the actual event list. This is something that would help anyway imho, since querying the interface from the script would let the user find out what events, properties, etc. are supported for an unknown (or poorly documented) object. However, what the developer seems most likely to support is more like this:
1. Script calls something like WantEvents(wHnd, "FunctionName").
2. Client queries the script engine for the address of "FunctionName" and puts that into a table.
3. When an event arrives, check to see if its not something like "The mouse just moved", then check its hWnd against the request list and call the script function that it has been connected to.
This is of course reinventing the wheel... But what can you do when the developer wants to be stubborn?
The whole point here is, in theory, to use the built in XML parser of the client to read a window layout you pre-made. So, if for example you want a map or picture list or even a button bar with lots of game specific functions/animations/text, you can create the interface, then when the client loads the script, rebuild your window from that description and have the "script" deal with what to do when all the buttons are pressed. Hopefully without the overhead and minimal amounts of non-portability to other platforms. Burying something like the HTML control or Webbrowser control from MS in there does a number of things I don't want any more than the developer does:
1. Adds extra memory requirements, above and beyond the client, script engine(s) being used (it supports plugins where every one can be running a different language, but comes with LUA as its default engine), the object someone loads with it and the script themselves.
2. Using those means you get all the extras that a browser or HTML control do, even if you don't want some or all of them. This includes any problems IE itself picks up along the way, especially on older versions of Windows.
3. It "may" limit what systems the client could run on, by creating minimum version issues.
4. The scripts for such systems are "not" compatible with the existing implimentation of scripts in the client (usually they are imbedded in the HTML page, not in a seperate engine).
5. Its about as portable as a 30 foot tall bronze elephant, since it would rely on a yet another Windows specific product, with its own interfaces and implimentations
Anyway, hopefully the answer is, "Yes, the client itself will receive all the events for any object the script it hosts has instanced." It will save me a lot of frustration. ;)
Situation: I "use" a client application that impliments script engine support, of multiple engines, and some callbacks for events specific to the client itself. Do to the nature of the client it is occationally useful to connect ActiveX controls into the script engine. For the most part these have all been ones with one-way interfaces, like ODBC, etc. However, it would be nice to be able to have events actually trigger one of the script functions.
Problems:
a. This seems stupidly complicated, at least to find any useful code examples for bloody doing it.
b. The one solution I have tracked down involves using ATL to bridge the controls through the client. The developer uses MFC though and is reluctant to impliment such a thing. Part of that is because he knows even lass about ATL than I do.
The actual questions:
1. When you instance an ActiveX object in a script engine "what" is the parent window for it? I personally assume that, since it needs one to work at all, that the parent will be the client that has instanced the engine, but I can't be 100% sure about that.
2. If I am right, then shouldn't the clients main event handler functions be recieving the events from such objects already? Or, in other words, if I do something like:
set a = CreateObject("VBDialog")
Won't the client itself get the "OK" or "Cancel" events from that dialogs window anyway, without having to use IConnectionPointContainer::Advise to link it directly to a function?
Frankly I think the developer is being overly paranoid about ATL possibly breaking or trying to impliment a more correct call to the ActiveX control's IUnknown to get the actual event list. This is something that would help anyway imho, since querying the interface from the script would let the user find out what events, properties, etc. are supported for an unknown (or poorly documented) object. However, what the developer seems most likely to support is more like this:
1. Script calls something like WantEvents(wHnd, "FunctionName").
2. Client queries the script engine for the address of "FunctionName" and puts that into a table.
3. When an event arrives, check to see if its not something like "The mouse just moved", then check its hWnd against the request list and call the script function that it has been connected to.
This is of course reinventing the wheel... But what can you do when the developer wants to be stubborn?
The whole point here is, in theory, to use the built in XML parser of the client to read a window layout you pre-made. So, if for example you want a map or picture list or even a button bar with lots of game specific functions/animations/text, you can create the interface, then when the client loads the script, rebuild your window from that description and have the "script" deal with what to do when all the buttons are pressed. Hopefully without the overhead and minimal amounts of non-portability to other platforms. Burying something like the HTML control or Webbrowser control from MS in there does a number of things I don't want any more than the developer does:
1. Adds extra memory requirements, above and beyond the client, script engine(s) being used (it supports plugins where every one can be running a different language, but comes with LUA as its default engine), the object someone loads with it and the script themselves.
2. Using those means you get all the extras that a browser or HTML control do, even if you don't want some or all of them. This includes any problems IE itself picks up along the way, especially on older versions of Windows.
3. It "may" limit what systems the client could run on, by creating minimum version issues.
4. The scripts for such systems are "not" compatible with the existing implimentation of scripts in the client (usually they are imbedded in the HTML page, not in a seperate engine).
5. Its about as portable as a 30 foot tall bronze elephant, since it would rely on a yet another Windows specific product, with its own interfaces and implimentations
Anyway, hopefully the answer is, "Yes, the client itself will receive all the events for any object the script it hosts has instanced." It will save me a lot of frustration. ;)