请问如何捕获该消息

slow_man 2002-10-30 09:06:55
我捕获了WM_KEYDOWN,但是不知怎么才能对『CTRL + F』热键进行处理。直接一点吧:我想在程序中启用『CTRL + F』热键,怎么实现,谢谢!
...全文
24 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
slow_man 2002-10-30
  • 打赏
  • 举报
回复
to kingcaiyao(AKing何金水)

有个消息:WM_HOTKEY,能不能给一个具体的例子?
kingcaiyao 2002-10-30
  • 打赏
  • 举报
回复
那你可以直接将CTRL+F注册为热键不就行了吗。
用RegisterHotKey函数,程序退出时用UnregisterHotKey对热键注销掉。。。
slow_man 2002-10-30
  • 打赏
  • 举报
回复
楼上的兄弟,你所说的只是对一个具体的窗口而言,我的应用程序用很多的窗口,我想直接对应用程序有效,该怎么做?
kingcaiyao 2002-10-30
  • 打赏
  • 举报
回复
Pls see the following codes:
void __fastcall TForm1::FormKeyDown(TObject *Sender,WORD &Key,TShiftState Shift)
{
if(Key=='F' && Shift.Contains(ssCtrl))
{
//add your code here
.....
}
}
keendom 2002-10-30
  • 打赏
  • 举报
回复
在BC的KeyDown事件中,有一个参数能够判断用户是否同时按下了CTRL键:

Occurs when a user presses any key while the control has focus.

typedef void __fastcall (__closure *TKeyEvent)(System::TObject* Sender, Word &Key, Classes::TShiftState Shift);
__property TKeyEvent OnKeyDown = {read=FOnKeyDown, write=FOnKeyDown};

Description

Use the OnKeyDown event handler to specify special processing to occur when a key is pressed. The OnKeyDown handler can respond to all keyboard keys, including function keys and keys combined with the Shift, Alt, and Ctrl keys, and pressed mouse buttons.

The TKeyEvent type points to a method that handles keyboard events.

The Key parameter is the key on the keyboard. For non-alphanumeric keys, use WinAPI virtual key codes to determine the key pressed. For more information, see Virtual Key codes.

The Shift parameter indicates whether the Shift, Alt, or Ctrl keys are combined with the keystroke.

Shift参数的含义如下:

Value Meaning
ssShift The Shift key is held down.
ssAlt The Alt key is held down.
ssCtrl The Ctrl key is held down.
ssLeft The left mouse button is held down.
ssRight The right mouse button is held down.
ssMiddle The middle mouse button is held down.
ssDouble The mouse was double-clicked.
gfh21cn 2002-10-30
  • 打赏
  • 举报
回复
protected:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_HOTKEY, TMessage, MyHotKey)
END_MESSAGE_MAP(TForm)



void __fastcall THT_Main::MyHotKey(TMessage & Msg)
{
if(Msg.WParam==uhotkey)
{
//....
}
}
gfh21cn 2002-10-30
  • 打赏
  • 举报
回复
ATOM uhotkey;//热键ID号

uhotkey=0x1100;
RegHotKeyOk=RegisterHotKey(Handle, uhotkey, VK_CTL, VK_F);

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧