odl or idl?
Hi All,
I have two projects that I am maintaining, both of which have COM
interfaces. One of the projects has an odl file with all of the
interface definitions in it and the other project has an idl.
I have been able to add enums to the idl file (that have generated .h
files automatically) so that I can #include and then use the enum in
the C++ prototypes within the project.
The project with the odl file doesn't seem to work the same. I can
add the enum to the odl file and change the interface prototypes to
use the enum, but no .h files are being generated so when I change the
c++ prototypes I get errors saying that I have an unexpected type (I
had to typedef the enum to get this far) Just to add to the confusion
the odl project uses MFC heavily and the odl file has AFX_ODL_PROP /
AFX_ODL_METHOD macros in it.
What is the difference between an idl and an odl file? The impression
I get is that odl files are obsolete, but can I just do a straight
swap for an idl? I tried this and class wizard fails plus it doesn't
seem to fix the problem.
I have noticed that the MIDL compiler on the odl project is set to
MkTypLib compatible mode. Also both projects are C++ and are using
Visual C++ 6.
To be honest I'm not sure if the problem is with MFC, ODL, IDL or me!
Ok some code snippets. This is from the odl project I cannot get to
compile. You will notice I use the typedef and enum keyword in
various places. Some articles seem to say I need to typedef enum and
others say this is not necessary. I'm really unsure what is needed as
far as the odl goes.
cpp file contains -
BEGIN_DISPATCH_MAP(CEdDoc, CDocument)
//{{AFX_DISPATCH_MAP(CEdDoc)
DISP_FUNCTION(CEdDoc, "SetDefaultPos", SetDefaultPos, VT_EMPTY, enum
ValidPositions) // This fails
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
h file -
class CEdDoc : public CDocument
{
// code removed for clarity
protected:
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CEdDoc)
afx_msg void SetDefaultPos(enum ValidPositions pos);
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
};
odl file -
[ uuid(19838AA2-0DBD-11D5-8A1D-0048548D8E8C), version(1.1) ]
library Ed
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(B7A470EB-ED39-4e13-B4F5-D5CC6386E23C),
v1_enum
]
typedef enum ValidPositions
{
CurrentPos = 0,
HighPos = 1,
MediumPos = 2,
LowPos = 3
} ValidPositions;
// Primary dispatch interface for CEdDoc
[ uuid(F526EC6C-09C5-4217-BC0F-53E7296476FC) ]
dispinterface IEd
{
methods:
//{{AFX_ODL_METHOD(CEdDoc)
[id(33)] void SetDefaultPos(ValidPositions pos);
//}}AFX_ODL_METHOD
};
[ uuid(2F6B315D-0D97-11D5-8A1D-0048548D8E8C) ]
coclass Document
{
[default] dispinterface IEd;
};
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
Thanks
Steve