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

zljsyd 2003-09-12 06:44:55
同上
...全文
75 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;
1) 本套课程针对高校大学生系统学习C语言而录制,从0基础入门讲起,循序渐进,通俗易懂,同时适用于计算机系及非计算机系的同学。通过学习可以帮助大家掌握C语言本质,轻松面对C语言全国二级考试,并达到能独立完成中型C项目、C游戏的水平;2) 多数高校都开设了C语言课程,网上C语言课程也很多,但普遍存在两个问题: (1) 授课方式单一,大多是照着代码念一遍, 对刚刚接触编程的同学来说,感觉晦涩难懂 (2) 授课内容过度注重语法,没有项目实战支撑,造成课程枯燥无趣。本课程针对上述问题进行了改进 (1) 授课方式采用语法讲解+内存布局示意图+项目的方式,让课程生动有趣好理解 (2) 系统全面的讲解了C语言的核心技术点,还配套录制了《全国计算机二级C语言真题精讲》,让学员在掌握C语言编程的同时,还能轻松面对二级考试;3) 课程详细内容: 常量-变量、分支语句、循环语句、操作符和表达式、函数(库函数、自定义函数、递归调用 )、数组(一维数 组、二维数组、数组作为函数参数、指针数组)、指针(指针和指针类型、二级指针和多级指针、指针表达式解析、指针运算、数 组指针、函数指针、回调函数)、调试技巧、程序环境和预处理(翻译环境、运行环境、预定义符号、#define和#undef、宏和函 数、条件编译、文件包含)、 数据在内存中的存储、内存块分配、static、字符函数和字符串函数、自定义类型(结构体、枚举 、联合)、动态内存管理、文件操作(i/o常量、i/o函数、流)。

3,245

社区成员

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

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