送分问题,MFC的ActiveX控件如何定义常量,如(#define flag 2)

zljsyd 2003-09-12 06:44:55
同上
...全文
73 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zljsyd 2003-09-15
  • 打赏
  • 举报
回复
谢谢各位!再请教一个问题,请问如何实现自定义消息,为什么在MFC中可以实现的自定义消息在ActiveX却不能通过
warmchang 2003-09-14
  • 打赏
  • 举报
回复
const unsigned int i = 22;就可以了。
plane1980 2003-09-14
  • 打赏
  • 举报
回复
#define 不行吗?
奇怪了
masterz 2003-09-13
  • 打赏
  • 举报
回复
Static Property Enumeration ODL allows for the creation of C/C++ style enumeration declarations that conform to the same rules as C/C++. Like C/C++, the new enumeration can be used as data type within the ODL file. While this style of enumeration is by far the easiest, it is also the most restrictive because the enumeration is static to the type library. The Alignment property is a good candidate for an enumeration because internally that is how it is validated and used. Listing 7.8 contains the code that was added to your ODL file to support the Alignment enumeration.

Remember to generate a new UUID for the enumeration with the GUIDGEN.EXE application included with VC++.

The helpstring is what the user will see within the property browser of your development environment. If you leave off the helpstring, the actual numeric value will appear instead.

The last thing you did was to change the data type of the Alignment property from long to EALIGNMENT. This is required if the property is to display the enumerated values within the property browser.



NOTE: ODL is very flexible in that it allows much the same style of data type declaration and use as that of C or C++. Any data type that can be declared in ODL can also be referenced and used within the same and other ODL files, including interface declarations. In addition, other type libraries can be imported into an ODL file to provide access to other user-defined data types. In the case of the sample control, two types of libraries, STDOLE_TLB and STDTYPE_TLB, are included for the standard OLE interface and data type declarations.

The ODL documentation can be a little difficult to decipher, but we recommend that you at least review the documentation. It is well worth the effort just to see what you can and cannot do with your type library and how it will affect the container of your control or component.

It is absolutely critical that the developer of containers adhere to the standards established in the ODL documentation. You will find that some of the aspects of type library creation and use are based on cooperation and trust and that component developers depend on that.



Listing 7.8 MFCCONTROL.ODL--EALIGNMENT Enumeration Added to the MFCControl.odl File
typedef
[ uuid(7F369B90-380D-11d0-BCB6-0020AFD6738C) ]
enum tagAlignmentEnum
{
[helpstring("Left Justify")] EALIGN_LEFT = 0,
[helpstring("Right Justify")] EALIGN_RIGHT = 1,
[helpstring("Center")] EALIGN_CENTER = 2,
}EALIGNMENT;

// Primary dispatch interface for CMFCControlWinCtrl

[ uuid(14DD5C04-60DE-11D0-BEE9-00400538977D),
helpstring("Dispatch interface for MFCControlWin Control"), hidden ]
dispinterface _DMFCControlWin
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CMFCControlWinCtrl)
[id(DISPID_READYSTATE), readonly] long ReadyState;
[id(1)] EALIGNMENT Alignment;
[id(DISPID_BACKCOLOR), bindable, requestedit] OLE_COLOR BackColor;
[id(2)] BSTR TextData;
//}}AFX_ODL_PROP
methods:
. . .

for more, go to
http://www.soldierx.com/books/ACTIVEX_PROGRAMMING_WITH_VISUAL_C++/ch07.htm#Heading11
for ATL
http://www.soldierx.com/books/ACTIVEX_PROGRAMMING_WITH_VISUAL_C++/ch09.htm#Heading14
Oversense 2003-09-12
  • 打赏
  • 举报
回复
const unsigned int i = 22;

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧