constants as #defines
Derek Bernhart -- derek_bernhart@affymetrix.com Tuesday, August 27, 1996 Environment: MSVC 4.2 Windows NT 4.0 I'm building an automation server and in addition to many methods and = properties I would like to define enumerative types and contants in my = interface. How do I go about doing so? In other words I would like = these contants and enum types to be exposed through my interface. Thanks, Derek
Dicky Singh -- Dicky@landmark.com Thursday, August 29, 1996 [Mini-digest: 3 responses] I cooked this ODL which shoud give you an idea (may not be really helpful though): Put constants inside an enumeration. check (Yeah limited to int constants: see t_GeneralPurposeConstants) The #defines won't show up in .h. check #definitions AAAA and BBBB and enums eAAAA and eBBBB. In code use eAAAA. In Interface methods use AAAA etc [ uuid(...) helpstring("..."), lcid(0x0409), version(1.0) ] library WhatALib { #define AAAA 100 #define BBBB 101 importlib("stdole32.tlb"); typedef enum { eMinBufferDimensions = 1, eMaxBufferDimensions = 128, } t_GeneralPurposeConstants; typedef enum { eAAAA = AAAA, eBBBB = BBBB } [ uuid(...), helpstring("..."), oleautomation, dual ] interface IDWhatever : IDispatch { typedef enum { Guy, Gal} t_Something; [propput, id(AAAA), bindable] HRESULT Fn([in] t_Something something); } ..... } ---------- From: Derek Bernhart[SMTP:derek_bernhart@affymetrix.com] Sent: Tuesday, August 27, 1996 2:06 p To: mfc list Subject: constants as #defines Environment: MSVC 4.2 Windows NT 4.0 I'm building an automation server and in addition to many methods and properties I would like to define enumerative types and contants in my interface. How do I go about doing so? In other words I would like these contants and enum types to be exposed through my interface. Thanks, Derek -------------------- Dicky Singh, Dicky@Landmark.COM Dragon Team. Landmark Systems Inc. 8000 Towers Crescent, Vienna VA 22182 -----From: "Jeffrey Smith"Derek, Declare your enum(s) in the public interface of your class declaration. That way your enum names will need to be scope to the declaring class. Constants are declared outside the class declaration in the header -- when used in the interface, but you can wrap them in a namespace. Jeff Wyvern Smith -----From: "John Elsbree" Derek - You can use the following construct in your interface's ODL file: typedef enum { north = 0, south = 180, east = 90, west = 270, } CompassDir; See Microsoft Knowledgebase article Q137354 (in your VC++ Books Online) for a complete example. John ("not speaking for Microsoft") Elsbree
| Вернуться в корень Архива |