Home > Back-end >  How hot press response only once
How hot press response only once

Time:10-11

I recently use hotkeys to implement a function, but found that registered the hot key, press the hotkey, message loop will constantly punishment hotkey events, has been triggered as long as you don't let go, is there any way to hold it triggers only once, your sincerely ask!!!!!!!!!! Can solve absolutely give points, 3 q!!!!!!!!!!

CodePudding user response:

Their top ahhh

CodePudding user response:

Stick your complete code come on up, turn head to Chou Chou

CodePudding user response:

How to sign up is not to say, the example code a lot, but if the following method hotkey press, will trigger,
Void __fastcall TForm1: : ApplicationEvents1Message (tagMSG & amp; Msg,
Bool & amp; Handled)
{
If (Msg) message==WM_HOTKEY)
{
}
}

CodePudding user response:

Well, that you have to change a train of thought, to see the MSDN, only Windows CE system support MOD_KEYUP flags

CodePudding user response:

I think of a way to, tried under a line still, you can try

 
#include
# pragma hdrstop

# include "Unit1. H"
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
//CTRL + f1
RegisterHotKey (Handle, 0 x1000, MOD_CONTROL, VK_F1);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
int i;
Void __fastcall TForm1: : DoHotKey ()
{
//response hotkey processing immediate cancellation of hot keys
UnregisterHotKey (Handle, 0 x1000);
Caption=IntToStr (+ + I);//accumulate a number in order to observe the
}

Void __fastcall TForm1: : aplctnvnts1Message (tagMSG & amp; Msg, bool & amp; Handled)
{
//when a key pop-up will register hotkey
If (Msg) message==WM_KEYUP)
RegisterHotKey (Handle, 0 x1000, MOD_CONTROL, VK_F1);

If (Msg) message==WM_HOTKEY)
DoHotKey ();
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Void __fastcall TForm1: : FormClose (TObject * Sender, TCloseAction & amp; The Action)
{
UnregisterHotKey (Handle, 0 x1000);
}

CodePudding user response:

In the hotkey handle events, determine the corresponding hotkeys if is in a state of press, don't repeat events elsewhere in the code,
  • Related