This code works fine for me:
frmMyForm = CREATEOBJECT("Form")
FrmMyForm.AddObject("oleObject1","oleComDialObject")
WITH FrmMyForm.OleObject1
.SetOptions()
.showopen()
?.FileName
ENDWITH
DEFINE CLASS oleComDialObject as OLEControl
OleClass ="MSComDlg.CommonDialog.1"
PROCEDURE SetOptions
#define COMMDLOG_DEFAULT_FLAG 0x00080000
#define COMMDLOG_RO 4
#define COMMDLOG_MULTFILES 512
This.Flags = COMMDLOG_DEFAULT_FLAG + COMMDLOG_RO + COMMDLOG_MULTFILES
This.FileName = "*.seq"
This.filter = "Stratus Log files|*.seq"
ENDPROC
ENDDEFINE
HTH
>>I am trying to use the Common Dialog Control, which I haven't used for a long time. I remember it used to work in the past. Now I'm getting an error in a new program I'm developing.
>Sample code:
#define COMMDLOG_DEFAULT_FLAG 0x00080000
#define COMMDLOG_RO 4
#define COMMDLOG_MULTFILES 512
oleCommDlog=CreateObject("MSComDlg.CommonDialog.1")
oleCommDlog.Flags = COMMDLOG_DEFAULT_FLAG + COMMDLOG_RO + COMMDLOG_MULTFILES
oleCommDlog.FileName = "*.seq"
oleCommDlog.filter = "Stratus Log files|*.seq"
oleCommDlog.ShowOpen()
>The ShowOpen() method fails with:
>"OLE IDispatch exception code 0 from CommonDialog: The common dialog function failed during initialization. This error often occurs when insufficient memory is available..."
>The system uses WinXP. Memory is plentiful. Message is BS.
Note that other functions in the same ActiveX Common Control, like ShowPrinter for example, work fine.
>The reason I need it is simply because I need multiple file selection, which I can't do with GetFile() (or can I?)
>Anybody has any idea why this error? Or a workaround?
>Thanks in advance,
>[UPDATE]: I just remembered there is a Solutions sample that showcases the Common Dialog Control. I checked thee sample provided in commdlg.scx and it works fine there. The code seems to me to be basically the same. The only difference is that the sample form has the ActiveX dropped on the form. My code is all in a PRG, using CreateObject(). Why would it not work in the same box? Strange.
>[2nd UPDATE]: I dropped the control in the form visually instead. It works!
Now why does it not work with CreateObject() and programmatic instantiation?
At least I have it working now.