word计算机二级宏,计算机二级C宏智者的利刃,愚者的恶梦-中-

计算机二级C宏智者的利刃,愚者的恶梦-中-

考试吧(Exam8.com) 2007-05-14 08:00:00 评论(0)条

(续上)例三、用c宏,自动生成代码这方面的例子也是多得很,不过有鉴于很多朋友不用很多编译器,不做嵌入式的开发,我就举个win平台的例子吧。我们知道mfc实现了windows的消息映射,比如: on_command(idm_about, onabout)

on_command(idm_filenew, onfilenew)

它是如何实现的idm_about和onabout的关联的呢?这要用到几个宏。

#define declare_message_map() /

private: /

static const afx_msgmap_entry _messageentries[]; /

protected: /

static afx_data const afx_msgmap messagemap; /

virtual const afx_msgmap* getmessagemap() const; /

#define begin_message_map(theclass, baseclass) /

const afx_msgmap* theclass::getmessagemap() const /

{ return &theclass::messagemap; } /

afx_comdat afx_datadef const afx_msgmap theclass::messagemap = /

{ &baseclass::messagemap, &theclass::_messageentries[0] }; /

afx_comdat const afx_msgmap_entry theclass::_messageentries[] = /

{ /

#define on_command(id, memberfxn) /

{ wm_command, 0, (word)id, (word)id, afxsig_vv, (afx_pmsg)memberfxn },

#define end_message_map() /

{0, 0, 0, 0, afxsig_end, (afx_pmsg)0 } /

}; /

#define declare_message_map() /

private: /

static const afx_msgmap_entry _messageentries[]; /

protected: /

static afx_data const afx_msgmap messagemap; /

virtual const afx_msgmap* getmessagemap() const; /

#define begin_message_map(theclass, baseclass) /

const afx_msgmap* theclass::getmessagemap() const /

{ return &theclass::messagemap; } /

afx_comdat afx_datadef const afx_msgmap theclass::messagemap = /

{ &baseclass::messagemap, &theclass::_messageentries[0] }; /

afx_comdat const afx_msgmap_entry theclass::_messageentries[] = /

{ /

#define on_command(id, memberfxn) /

{ wm_command, 0, (word)id, (word)id, afxsig_vv, (afx_pmsg)memberfxn },

#define end_message_map() /

{0, 0, 0, 0, afxsig_end, (afx_pmsg)0 } /

}; /

嘿嘿,就这么几个宏,就构造出一个消息数组来.

展开全文

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值