Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Two things to remedy this: use include instead of import; or put (a reference to) your interface inside a library block. "Michael Pokerschnig" <michael_pokerschnig@sbu1.storkgroup.com> wrote: > Hi, > > I want to import an source interface wich I put in a separate .idl file to > save retyping it all the time i need it. > The MIDL compiles without any error, but if I look at the generated header > file I cannot find the imported interface ! > > why ? > is there something wrong defined ? > > kind regards > Mike. > > > This is the interface which i put in the file CP.idl as it is my connection > point: > ------------------------------------------------------------ -- > [ > object, > uuid(B6151303-82FA-11d3-8209-00508B03223A), > ] > interface ITest : IUnknown > { > [helpstring("method GetWidthMM")] HRESULT GetWidthMM([out] double* > u_pdbWidth); > }; > ------------------------------------------------------------ - > > the I try to import it in my .idl file of the COM object: > > ------------------------------------------------------------ - > import "oaidl.idl"; > import "ocidl.idl"; > > [ > object, > uuid(B6151300-82FA-11d3-8209-00508B03223A), > ] > interface IFlop : IUnknown > { > [id(1), helpstring("method DoUI")] HRESULT DoUI(); > } > > [ > uuid(2B6BF8B6-8537-11D3-8209-00508B03223A), > version(1.0), > helpstring("Flop 1.0 Type Library") > ] > library FLOPLib > { > importlib("stdole32.tlb"); > importlib("stdole2.tlb"); > > import "CP.idl"; // I import it exactly where it was when I first > created this interface with the wizzard ! > > [ > uuid(2B6BF8C4-8537-11D3-8209-00508B03223A), > helpstring("FlopModul Class") > ] > coclass FlopModul > { > [default] interface IFlop; > [default, source] interface ITest; // here i use the interface > imported from CP.idl > }; > }; > ------------------------------------------------------------ -
Add a library block for your interface and then importlib() your type library instead. You don't need to import the IDL in this case, but you can if you wish - just move the import line to the begining along with the other imports. Then it might be good idea to have two IDLs for the interface, the first where you define it and you import it in your new IDL, and the second where you import the interface definition only to build a type library from it: import "oaidl.idl"; import "ocidl.idl"; import "itf.idl" [...] library ItfLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); interface IMyItf; }; -- =============================== Alexander Nickolov, MCSD Panasonic Technologies Inc. Speech Technology Laboratory email: agnickolov@geocities.com =============================== Michael Pokerschnig wrote in message <7v9vm5$bnv$1@fleetstreet.Austria.EU.net>... > Hi, > > I want to import an source interface wich I put in a separate .idl file to > save retyping it all the time i need it. > The MIDL compiles without any error, but if I look at the generated header > file I cannot find the imported interface ! > > why ? > is there something wrong defined ? > > kind regards > Mike. > > > This is the interface which i put in the file CP.idl as it is my connection > point: > ------------------------------------------------------------ -- > [ > object, > uuid(B6151303-82FA-11d3-8209-00508B03223A), > ] > interface ITest : IUnknown > { > [helpstring("method GetWidthMM")] HRESULT GetWidthMM([out] double* > u_pdbWidth); > }; > ------------------------------------------------------------ - > > the I try to import it in my .idl file of the COM object: > > ------------------------------------------------------------ - > import "oaidl.idl"; > import "ocidl.idl"; > > [ > object, > uuid(B6151300-82FA-11d3-8209-00508B03223A), > ] > interface IFlop : IUnknown > { > [id(1), helpstring("method DoUI")] HRESULT DoUI(); > } > > [ > uuid(2B6BF8B6-8537-11D3-8209-00508B03223A), > version(1.0), > helpstring("Flop 1.0 Type Library") > ] > library FLOPLib > { > importlib("stdole32.tlb"); > importlib("stdole2.tlb"); > > import "CP.idl"; // I import it exactly where it was when I first > created this interface with the wizzard ! > > [ > uuid(2B6BF8C4-8537-11D3-8209-00508B03223A), > helpstring("FlopModul Class") > ] > coclass FlopModul > { > [default] interface IFlop; > [default, source] interface ITest; // here i use the interface > imported from CP.idl > }; > }; > ------------------------------------------------------------ - > >
Thanks, I found the #include, therefore I simply added the .idl into the project to get I shurely maked. As you expected it only worked at the beginning of the file. Mike. Vladimir Hristov <vhristov@code.bg> wrote in message news:e2pjtMeI$GA.251@cppssbbsa05... > When you use import directive to import one IDL file into another, MIDL just > puts signle #include statement in the generated header file. That's why you > can't see the imported interface. Let's suppose you have files A.IDL and > B.IDL and you want to import file B in A. Then the situation will look like > this: > > // A.IDL starts here > ... > import "B.IDL"; > ... > > > // Geenrated A.H starts here > ... > #include "B.H"; > ... > > So, there is no problem to use interfaces from B.IDL. > I'm not sure about importing the file in library section, but if you have > problems you can try to move the import "CP.IDL" at the begining of the > file. > > Regards, > Vlado > > > > Michael Pokerschnig <michael_pokerschnig@sbu1.storkgroup.com> wrote in > message news:7v9vm5$bnv$1@fleetstreet.Austria.EU.net... >> Hi, >> >> I want to import an source interface wich I put in a separate .idl file to >> save retyping it all the time i need it. >> The MIDL compiles without any error, but if I look at the generated header >> file I cannot find the imported interface ! >> >> why ? >> is there something wrong defined ? >> >> kind regards >> Mike. >> >> >> This is the interface which i put in the file CP.idl as it is my > connection >> point: >> ------------------------------------------------------------ -- >> [ >> object, >> uuid(B6151303-82FA-11d3-8209-00508B03223A), >> ] >> interface ITest : IUnknown >> { >> [helpstring("method GetWidthMM")] HRESULT GetWidthMM([out] double* >> u_pdbWidth); >> }; >> ------------------------------------------------------------ - >> >> the I try to import it in my .idl file of the COM object: >> >> ------------------------------------------------------------ - >> import "oaidl.idl"; >> import "ocidl.idl"; >> >> [ >> object, >> uuid(B6151300-82FA-11d3-8209-00508B03223A), >> ] >> interface IFlop : IUnknown >> { >> [id(1), helpstring("method DoUI")] HRESULT DoUI(); >> } >> >> [ >> uuid(2B6BF8B6-8537-11D3-8209-00508B03223A), >> version(1.0), >> helpstring("Flop 1.0 Type Library") >> ] >> library FLOPLib >> { >> importlib("stdole32.tlb"); >> importlib("stdole2.tlb"); >> >> import "CP.idl"; // I import it exactly where it was when I first >> created this interface with the wizzard ! >> >> [ >> uuid(2B6BF8C4-8537-11D3-8209-00508B03223A), >> helpstring("FlopModul Class") >> ] >> coclass FlopModul >> { >> [default] interface IFlop; >> [default, source] interface ITest; // here i use the > interface >> imported from CP.idl >> }; >> }; >> ------------------------------------------------------------ - >> >> > >
When you use import directive to import one IDL file into another, MIDL just puts signle #include statement in the generated header file. That's why you can't see the imported interface. Let's suppose you have files A.IDL and B.IDL and you want to import file B in A. Then the situation will look like this: // A.IDL starts here ... import "B.IDL"; ... // Geenrated A.H starts here ... #include "B.H"; ... So, there is no problem to use interfaces from B.IDL. I'm not sure about importing the file in library section, but if you have problems you can try to move the import "CP.IDL" at the begining of the file. Regards, Vlado Michael Pokerschnig <michael_pokerschnig@sbu1.storkgroup.com> wrote in message news:7v9vm5$bnv$1@fleetstreet.Austria.EU.net... > Hi, > > I want to import an source interface wich I put in a separate .idl file to > save retyping it all the time i need it. > The MIDL compiles without any error, but if I look at the generated header > file I cannot find the imported interface ! > > why ? > is there something wrong defined ? > > kind regards > Mike. > > > This is the interface which i put in the file CP.idl as it is my connection > point: > ------------------------------------------------------------ -- > [ > object, > uuid(B6151303-82FA-11d3-8209-00508B03223A), > ] > interface ITest : IUnknown > { > [helpstring("method GetWidthMM")] HRESULT GetWidthMM([out] double* > u_pdbWidth); > }; > ------------------------------------------------------------ - > > the I try to import it in my .idl file of the COM object: > > ------------------------------------------------------------ - > import "oaidl.idl"; > import "ocidl.idl"; > > [ > object, > uuid(B6151300-82FA-11d3-8209-00508B03223A), > ] > interface IFlop : IUnknown > { > [id(1), helpstring("method DoUI")] HRESULT DoUI(); > } > > [ > uuid(2B6BF8B6-8537-11D3-8209-00508B03223A), > version(1.0), > helpstring("Flop 1.0 Type Library") > ] > library FLOPLib > { > importlib("stdole32.tlb"); > importlib("stdole2.tlb"); > > import "CP.idl"; // I import it exactly where it was when I first > created this interface with the wizzard ! > > [ > uuid(2B6BF8C4-8537-11D3-8209-00508B03223A), > helpstring("FlopModul Class") > ] > coclass FlopModul > { > [default] interface IFlop; > [default, source] interface ITest; // here i use the interface > imported from CP.idl > }; > }; > ------------------------------------------------------------ - > >