Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Common Dialog: ShowOpen() errors out
Message
From
21/12/2004 13:10:23
 
 
To
21/12/2004 12:43:08
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00971064
Message ID:
00971076
Views:
84
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:
* setup Common Dialog Control
#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"
* Display file dialog
oleCommDlog.ShowOpen()   && <== IDispatch exception: insuff. memory error here
>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.
Apoya a Visual FoxPro usandolo legalmente
--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º
Espartaco Palma Martínez
SysOp PortalFox
http://www.portalfox.com
esparta@portalfox.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform