I am working with an ActiveX control in Internet Explorer 8 that is to display a save file dialog which let's the user choose a file name and file type (jpg, gif, etc). These values get passed to code and then are used in a different method to save the file. Unfortunately the method that invokes the dialog has no return value, and the file name and file type are passed in as out parameters.
The signature of the method (expressed in Visual Basic) looks like this:
Public Sub SaveFileDialog( _
ByVal bstrDialogType As Variant, _
ByRef pbstrFileName As String, _
ByRef out_pvType As Long _
)
The two ByRef parameters are the out parameters.
I have written the following JavaScript code:
try
{
var saveFileName, saveFileType; // out variables
gxVideoPlayBack.SaveFileDialog("image", saveFileName, saveFileType);
alert(saveFileName); // displays "undefined"
alert(saveFileType); // displays "undefined"
}
catch(error)
{
if(!error.number === -2147221484) // User clicked cancel.
{
alert(error.message);
}
}
The code works in that the ActiveX control produces its dialog, and I can handle error conditions, but I can't seem to figure out how to capture the values of the out parameters.
In the code gxVideoPlayBack is a reference to the ActiveX control embedded in the DOM via an HTML element.
If JavaScript will not work for this, can it be done in VBScript?
As an alternative I can just implement my own dialog, but would rather use the one provided.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…