描述:
刚学vc,什么都不懂,我要做一个消息转发的东西,用com组件(alt)来接收消息,这对把?
有没有简单的例子演示一下呢?到底怎么弄呢?com提供接口,这个比较抽象,到底如何实现呢?有没有相关的资料来理解一下呢?在线等~~~
解决方案1:
有两种方法可以创建com:
1.用MFC的建立重量级com:
1).如果建立dll的com,可以选MFC DLL,然后在附件功能里面选支持自动化。
2).如想建立EXE型的com,可以在第三步选Automation支持自动化。
3).如果你建立工程时忘记了,可以以后在工程里面手工加入,不过这就要看你的本领了,最好不要这样!
2.用ATL建立轻量级COM。
在向导中选ATL COM Wizard,,,,然后再添加ATL简单对象,具体不讲了。。。
转发消息,楼上也讲了,不说了。。
Sometimes your application will not automatically be sent WM_KEYDOWN messages for accelerator keys. In this case, you must manually send this message to your window. Here is a sample message pump that sends all keyboard messages to the window of your application:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
// Send all keyboard messages to the window of your
// application. hwndApp is the window handle of
// your application.
//
if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST)
::SendMessage(hwndApp, msg.message, msg.wParam, msg.lParam);
DispatchMessage(&msg);
}