COM中CWnd或其它窗口类型不能使用消息

Crob Crob 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在一个COM组件中,有一个CWnd窗口,在里面定义了自定义消息,但是在COM中无论是PostMessage还是SendMessage,该窗口都收不到这个消息。在外面使用这个CWnd类都是好用的,一放到COM中就收不到消息了。

另外调用COM组件的是控制台程序,CWnd用如下方法创建:
另外我还试过ATL的Window模板类,也不能使用消息。

WNDCLASSEX wndclass;
wndclass.cbSize=sizeof wndclass;
wndclass.style=0;
wndclass.lpfnWndProc=WindowProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=GetModuleHandle(0);
wndclass.hIcon=0;
wndclass.hCursor=0;
wndclass.hbrBackground=0;
wndclass.lpszMenuName=0;
wndclass.lpszClassName=_T("Helper Window");
wndclass.hIconSm=0;

RegisterClassEx(&wndclass);
m_hWnd=CreateWindow(_T("Helper Window"), _T("Helper Window"), 0, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(0));
...全文
评论 7
收藏 已收藏
分享
返回顶部
Crob
ATL 3,248 成员 48,530 内容