需要帮助HANDLE_MSG [英] Need help with HANDLE_MSG
本文介绍了需要帮助HANDLE_MSG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Visual C ++
我正在尝试设置F1的热键来调用我的软件中的例程。我已经能够注册热键但无法获取编译代码以尝试在按下热键时执行操作。我不知道如何处理WM_HOTKEY。
代码:
Visual C++
I am trying to set up a hot key of "F1" to call a routine within my software. I have been able to register the hot key but can not get the code to compile to try to take action when the hot key is pressed. I don''t know how to handle WM_HOTKEY.
Code:
include windowsx.h
//this seems to be working. if I call it a 2nd time it fails
if(!RegisterHotKey(NULL, IDC_OP_START, 0, 0x70)) MessageBox("F1 Register Failed");
WPARAM wParam;
LPARAM lParam;
HANDLE_MSG(NULL, WM_HOTKEY, OnStartTest)
void COpui::OnStartTest()
{
//my routine in here
}
错误!!
错误C2046:非法案件
错误''HANDLE_WM_HOTKEY'':未声明的标识符
好像HANDLE_MSG函数不喜欢我传递WM_HOTKEY。
ERROR!!
error C2046: illegal case
error ''HANDLE_WM_HOTKEY'' : undeclared identifier
Seems like the HANDLE_MSG function does not like me passing WM_HOTKEY.
推荐答案
我认为你需要花一些时间学习Windows编程,然后才能尝试这样的高级主题。这个。您不能只在代码中间转储case
语句,并希望它能够执行某些操作。HANDLE_MSG
宏设计用于程序的Windows消息处理函数中的switch {}
块内。
I think you need to spend some time learning about Windows programming before trying such advanced topics as this. You cannot just dump acase
statement in the middle of your code and expect it to do something. TheHANDLE_MSG
macro is designed to be used inside aswitch {}
block in the windows message handler function of your program.
您没有显示导致此问题的源代码。找不到标识符HANDLE_WM_HOTKEY
,但您显示的源代码使用WM_HOTKEY
,它将使用windows进行编译。 h:
http ://msdn.microsoft.com/en-us/library/windows/desktop/ms646279%28v=vs.85%29.aspx [ ^ ]。
比较: http://support.microsoft.com/kb/83456 [ ^ ]。HANDLE_MSG
是用于实现窗口过程的宏(以蹩脚的C ++方式,在我看来:-)) :
http:/ /msdn.microsoft.com/en-us/library/windows/desktop/ff468931%28v=vs.85%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library /windows/desktop/ms632593%28v=vs.85%29.aspx [ ^ ]。
回答后续问题:是的,这个令人遗憾的''##''运营商,你以前从未提及过。这里解释:
http:/ /msdn.microsoft.com/en-us/library/09dwwt6y%28v=vs.110%29.aspx [ ^ ]。
所有这些预处理器活动和这种消息处理方式是如此蹩脚!我可以看到它吗? :-)
-SA
You are not showing source code which causes this problem. The identifierHANDLE_WM_HOTKEY
, is not found, but the source code you show usesWM_HOTKEY
which will be compiled with "windows.h":
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646279%28v=vs.85%29.aspx[^].
Compare: http://support.microsoft.com/kb/83456[^].HANDLE_MSG
is the macro used to implement window procedure (in a lame C++ way, in my opinion :-)):
http://msdn.microsoft.com/en-us/library/windows/desktop/ff468931%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632593%28v=vs.85%29.aspx[^].
In response to the follow-up question: yes, this token-pasting ''##'' operator you never mentioned before. It is explained here:
http://msdn.microsoft.com/en-us/library/09dwwt6y%28v=vs.110%29.aspx[^].
All this preprocessor activity and this way of message handling is such a lame! Can I unsee it? :-)
—SA
这篇关于需要帮助HANDLE_MSG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文