Results 1 to 8 of 8

Thread: ActiveX DLL exporting enums, types... (resolved)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    ActiveX DLL exporting enums, types... (resolved)

    I'm making an ActiveX DLL (ATL COM) in C++ .NET, and i'm using it in Visual Basic 6.0...

    I do not know how to make enums and types (struct) to be visible when I use the ActiveX in VB ?

    Also, how do I add modules to the ActiveX ? (cuz right now I'm using only classes, that's it...)
    Last edited by CVMichael; Jan 28th, 2003 at 04:59 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    As for user types, you can't. VB does not accommodate you, you must accommodate VB. You have to declare the structs in IDL syntax in the IDL file. The MIDL compiler will then create a struct definition that you must use. This will also be visible in VB.
    ms-help://MS.VSCC/MS.MSDNVS/automat/htm_hh2/chap12_2bqr.htm
    I fear enums are completly impossible as VB doesn't understand the concept of enums (or does it? I'm not sure). But you can define a series of constants in the IDL file (that's what DAO does).

    What do you mean by modules?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Ok, it seems to support enums, pretty much the same way as structs: via IDL.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    I don't get it... i've been trying to make this work for hours...

    Your saying to make changes in the idl file, but in the readme.txt it says that the file is created everytime I buid the project, so then whatever I type in there, it will be erased...

    And when I DID modify the idl file, after I compiled the project I got this message:



    Is there a way to make the WAVEFORMATEX public to VB in the interface thing ?
    This is the code I have now...
    Code:
    [
    	object,
    	uuid("FB57A655-8BF1-460A-9B3D-79729663BB00"),
    	dual,	helpstring("IACMClass Interface"),
    	pointer_default(unique)
    ]
    __interface IACMClass : IDispatch
    {
    	[id(1), helpstring("method ChooseSourceFormat")] HRESULT ChooseSourceFormat([out, retval] LONG* retval);
    	[id(2), helpstring("method ChooseDestinationFormat")] HRESULT ChooseDestinationFormat([out,retval] LONG* retval);
    };
    
    // CACMClass
    
    [
    	coclass,
    	threading("apartment"),
    	event_source("com"),
    	vi_progid("CMikeClasses.ACMClass"),
    	progid("CMikeClasses.ACMClass.1"),
    	version(1.0),
    	uuid("6DB24413-3770-45FA-87D7-7523839EAC22"),
    	helpstring("ACMClass Class")
    ]
    class ATL_NO_VTABLE CACMClass : 
    	public IACMClass
    {
    protected:
    	PWAVEFORMATEX s_format;
    	PWAVEFORMATEX d_format;
    
    	LONG ChooseFormat(PWAVEFORMATEX *pwfx);
    public:
    
    	CACMClass(){}
    
    	DECLARE_PROTECT_FINAL_CONSTRUCT()
    
    	HRESULT FinalConstruct(){ return S_OK; }
    	void FinalRelease(){}
    
    public:
    	STDMETHOD(ChooseSourceFormat)(LONG* retval);
    	STDMETHOD(ChooseDestinationFormat)(LONG* retval);
    	STDMETHOD(ChooseFilter)(LONG* retval);
    };
    Attached Images Attached Images  

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    I figured it out...

    For the people that are doing the same thing...

    Put this code at the beginnin of my previous code (the interfce and the class has to see them)
    Code:
    [export, v1_enum] 
    enum eList { 
       e1 = 1, 
       e2 = 2
    };
    
    [export]
    struct MYFLOT {
       int i;
    };
    
    // to export an already defined struct you will have to rename it, like this (I put a "t" in front)
    [export]
    typedef struct tWAVEFORMATEX WAVEFORMATEX;
    And you HAVE to use them in a method or property, otherwise they will not show up

    So, in the class, do something like
    Code:
    public:
    	STDMETHOD(func)( MYFLOT* myStruct ) { return S_OK; }
    	STDMETHOD(func2)( eList* myEnum ) { return S_OK; }
    	STDMETHOD(func3)( WAVEFORMATEX* myStruct ) { return S_OK; }
    And don't forget to add them in the __interface too
    Last edited by CVMichael; Jan 28th, 2003 at 12:33 AM.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    More problems...

    When I do that (the code I pasted previously), I get this error "Variable uses an Automation type not supported in Visual Basic" when I try to use the type (struct)

    The enum works fine... but can't figure out what's wrong with the struct thing...

    So... ANYONE... please help me... i'm trying to figure this thing out for 2 days !!

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    OK... it seems that whenever I post a question here, shortly after that I find the anser on my own... I should do that more often

    I was paying so much attention the the "export" thing, and what should I do with that to fix it, that I did not see that I was using WORD variable types (that are unsigned short) and of course, Visual Basic does not support unsigned....

    So, I changed my variables to just short, and it works now... again...


    Odd..... it really feels like there is no one else there on the net (this forum), I'm kinda like talking to myself...

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Sorry, I have to sleep sometimes, too.

    Anyway, I didn't know you're using VC++ attributes. Yes, if you do that then the IDL file is automatically generated.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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