今年夏天,我在写MSDN上的ATL示例project Polygon时,添加事件后出现了一下六个错误:
error C2065: 'IID__IPolyCtlEvents' : undeclared identifier
error C2440: 'static_cast' : cannot convert from 'class CPolyCtl *' to 'class ATL::_ICPLocator *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
fatal error C1903: unable to recover from previous error(s); stopping compilation
error C2065: 'IID__IPolyCtlEvents' : undeclared identifier
error C2440: 'static_cast' : cannot convert from 'class CPolyCtl *' to 'class ATL::_ICPLocator *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
当时也不知道怎么解决,明明是根据原文仔细认真编写的,怎么会出错误呢?浪费了很多时间,在网上也没找的解救办法。后来,经过本人不懈的努力,终于把问题解决了,特写此稿,与同志们分享。
当我们 Go to definition of IID__IPolyCtlEvents,在Polygon_i.c文件中我们可以看到这样的这样的定义:
const IID DIID__INextCtlEvents = 0x79A66825,0x81D1,0x4233,0x83,0xF3,0x8E,0xA4,0xF8,0xBB,0x2B,0x4C}};
当我们把CONNECTION_POINT_ENTRY(IID__INextCtlEvents)改为CONNECTION_POINT_ENTRY(DIID__INextCtlEvents)后,
问题就这么解决了!呵呵。