菜鸟才开始学,希望各位大大指教
解决方案 »
- 使用CoolBar和Toolbar菜单融合的问题
- PostMessage的疑问?
- 如何在dbgrid中实现动态查找功能,并显示出来供选择?
- 关于类型转换
- datetimepicker 控件显示时间的问题,高手请进!在线等待!
- 请问那有FastReport2.4下载???
- 'Let's talk about how we can stop making retarded posts like this one'的准确翻译!
- 刚刚下载了一个控件不好用
- 关于TTreeNode的儿子和兄弟的问题,我错在哪?
- 请教在delphi中如何实现form最小化时,变成一个图标出现在左下角状态栏?(相当于BCB的TrayIcon1)
- 新手请教:怎样获取数组长度
- ADO的存储过程的问题,顶者有分
自己查MSDN去,可以全局也可针对某窗口的
这样对不对?
我需要一个例程,有人愿意给我一个吗?
HWND hWnd,
int id,
UINT fsModifiers,
UINT vk );Parameters
hWnd
[in] Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
id
[in] Identifier of the hot key. No other hot key in the calling thread should have the same identifier. An application must specify a value in the range 0x0000 through 0xBFFF. A shared dynamic-link library (DLL) must specify a value in the range 0xC000 through 0xFFFF.
fsModifiers
[in] Specifies keys that must be pressed in combination with the key specified by the nVirtKey parameter in order to generate a WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values:
Value Description
MOD_ALT Either ALT key must be held down.
MOD_CONTROL Either CTRL key must be held down.
MOD_KEYUP Both key up events and key down events generate a WM_HOTKEY message.
MOD_SHIFT Either SHIFT key must be held down.
MOD_WIN Either WINDOWS key was held down. These keys are labeled with the Microsoft Windows logo.
vk
[in] Specifies the virtual-key code of the hot key.
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. Res
When a key is pressed, the system looks for a match against all hot keys. Upon finding a match, the system posts the WM_HOTKEY message to the message queue of the thread that registered the hot key. This message is posted to the beginning of the queue so it is removed by the next iteration of the message loop. RegisterHotKey can be used to register hot keys across threads.RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key. If the window identified by the hWnd parameter already registered a hot key with the same identifier as that specified by the id parameter, the new values for the fsModifiers and vk parameters replace the previously specified values for these parameters. 然后响应WM_HOTKEY
procedure WMHotKey(var msg:TMessage);message TWM_HOTKEY;
begin
if msg.lParam=VK_F12 then
MessageBox('F12 Pressed');
end;
procedure WMHotKey(var msg:TMessage);message TWM_HOTKEY;
begin
if msg.lParam=VK_F12 then
MessageBox('F12 Pressed');
end;
改为然后响应WM_HOTKEY
procedure WMHotKey(var msg:TMessage);message TWM_HOTKEY;
begin
if msg.lParamHi=VK_F12 then
MessageBox('F12 Pressed');
end;调试时
RegisterHotKey(Handle,0,MOD_ALT,VK_F12);
Alt+F12避免出现CPU框