I've about decided that this whole OCX thing is a bunch of crap.
On a test machine (no development environment), I have found that even if the OCX is installed, it seems that you cannot easily test for it. As you inferred earlier, this construct:
CREATEOBJECT("MSComDlg.CommonDialog.1")
always fails on an "unlicensed" machine.
The alternative: If you just go ahead and use the control on a form but the control is not registered on the machine, you've got to capture the OLE error at a weird time (when the form is instantiating).
Can you tell me, if you put the control on a form, how do you create a try/catch construct to "catch" the failure of the control to instantiate on the form? Basically, I need to catch the OCX failure when it's not registered on the machine so that I can fall back to GetFile().
What do you recommend? Thanks gain.
>You've to distribute comdlg32.ocx with your application to make sure that it works.
>
>>Thanks Sergery. Let me ask one final question... as I'm not sure just how pervasively available is MSComDlg.CommonDialog.
>>
>>What if I try to open a form with the MSComDlg.CommonDialog control on it, but the machine does not have the control installed. Is that even possible (and still the system be functional?).
>>
>>I have tried this, and it seems to work:
>>
>>
>>
>>IF EMPTY(G_CanUseCommonDlg)
>> G_CanUseCommonDlg=1
>> LOCAL oOleComDlg
>> TRY
>> oOleComDlg=CREATEOBJECT("MSComDlg.CommonDialog.1")
>> CATCH
>> G_CanUseCommonDlg=2
>> ENDTRY
>> oOleComDlg=.null.
>>ENDIF
>>By doing this, I know if G_CanUseCommonDlg equals 1, that MSComDlg.CommonDialog.1 is available and my app won't throw an error when I open the form upon which the Control is placed. By the way, I set the form's LEFT property to -500 in the Init so the form itself is not visible. Then in its Activate event, I do the code to set up the OleControl and invoke its ShowOpen() method. This seems to work OK.
>>If G_CanUseCommonDlg equals 2, then I just default to VFP's GetFile() function.
>>
>>What I don't know is if GetFile() uses MSComDlg.CommonDialog anyway, so that all this checking I'm doing is not necessary.