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);
{
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);
}
1.用MFC的建立重量级com:
1).如果建立dll的com,可以选MFC DLL,然后在附件功能里面选支持自动化。
2).如想建立EXE型的com,可以在第三步选Automation支持自动化。
3).如果你建立工程时忘记了,可以以后在工程里面手工加入,不过这就要看你的本领了,最好不要这样!
2.用ATL建立轻量级COM。
在向导中选ATL COM Wizard,,,,然后再添加ATL简单对象,具体不讲了
转发消息,楼上也讲了,不说了。。