CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 1999
    Location
    France
    Posts
    393

    import IDL file in MFC project

    Hi,

    I have a big MFC project, already using ocx's and exe server's where I use the #import function to include their methods.
    The project is not in UNICODE this is a very simple MFC project, using some COM functionnality but only through SmartPointers or COleDispatch...

    Now I need to include in this big project a new declaration of objects from an IDL file.
    But just using midl to generate tlb file gives me lot of UNICODE things with wide char and so on and really no facilities to use it (looking through Internet shows that with .NET it is simpler)

    Is it possible to generate from the idl file directly a tlh and tli that defines interfaces like importing an OCX with BSTR and stuff like that and the SmartPointer.

    I have tried to use directly #import but of course it does not work.

    It is to reduce the work of course ;-))

    Please can someone help on that?


    Thanks a lot

  2. #2
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: import IDL file in MFC project

    Quote Originally Posted by F.Mayis
    Now I need to include in this big project a new declaration of objects from an IDL file.
    IDL file contains only interface definitions - not objects.

    IDL = Interface Definition Language

    Quote Originally Posted by F.Mayis
    But just using midl to generate tlb file gives me lot of UNICODE things with wide char and so on and really no facilities to use it
    What do you mean by "things"?

    And, why are the things a problem?

    Is it possible to generate from the idl file directly a tlh and tli that defines interfaces like importing an OCX with BSTR and stuff like that and the SmartPointer.
    You need to get these from a Type Library, and not from an IDL.

    Code:
    Compile IDL --> Get TLB 
    
    #import "TLB" --> Use Interfaces
    And...
    Quote Originally Posted by F.Mayis
    I have tried to use directly #import but of course it does not work.
    Where did you do this? Post code.

  3. #3
    Join Date
    Sep 1999
    Location
    France
    Posts
    393

    Re: import IDL file in MFC project

    Hi,

    Thanks for the quick answer

    And in fact I think I have it.
    I have generated from the idl files the TLB.
    Then just done an import of these TLB files and it seems to work.

    Exactly as you say in your post.

    Thanks again

  4. #4
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: import IDL file in MFC project

    Great... Using the TLB is the correct way to access a COM Server...

  5. #5
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: import IDL file in MFC project

    On a related note, it is possible to import an external IDL in a project's IDL, like this -
    Code:
    import "ServersIDL.idl";
    ...In the Project's IDL File.

    However, this creates a strong bind between the Server and Client, and must be avoided to the extent possible.

  6. #6
    Join Date
    Sep 1999
    Location
    France
    Posts
    393

    Re: import IDL file in MFC project

    thanks for the precision

  7. #7
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: import IDL file in MFC project

    You are welcome...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured