[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

How can I get ctrl + F10 pressed in my application?

Hello guys,

I drop this component ApplicationEvents and I need to catch ctrl + F10 when user press in any part of my application,

How can I do this with applicationEvents?

crtl + F10

thanks
0
hidrau
Asked:
hidrau
  • 5
  • 4
1 Solution
 
2266180Commented:
well, there is this issue with the F10 since it's being used to activate the form menu (similar with alt key).

see the following code:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (msg.message=WM_KEYUP) and (KeyboardStateToShiftState=[ssctrl]) and (msg.wParam=VK_F10) then
    showmessage('ctrl+F10 pressed');
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key=vk_f10) and (ssctrl in shift) then
    showmessage('1');
end;

the onkeyup event works fine.
the applicationevents will not work for F10 but will work just fine fo other keys. that is because pressing F10 will not fire teh application events. setting the form keypreview to true doesn't fix it either.

so there is a workaround without using the applicationevents. is this ok for you?
0
 
hidrauAuthor Commented:
weird that I tested this code and nothing happened

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (msg.message=WM_KEYUP) and (KeyboardStateToShiftState=[ssctrl]) and (msg.wParam=VK_F10) then
    showmessage('ctrl+F10 pressed');
end;

are you sure about that?
0
 
hidrauAuthor Commented:
What does this "handled : Boolean" in the function serve for?

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
hidrauAuthor Commented:
I tested without this (msg.message=WM_KEYUP) and worked, but it repeated twice the showmessage.

Is this the reason for using this part of the code?

0
 
2266180Commented:
you did not read my entire message.
so,  "the applicationevents will not work for F10 but will work just fine fo other keys". so I never said that it works like that, but that it works with otehr keys.

now I thought a little since you mentioned that the message appeared and looked at what message does that and if you change it to:

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (msg.message=WM_SYSKEYUP) and (KeyboardStateToShiftState=[ssctrl]) and (msg.wParam=VK_F10) then
    showmessage('ctrl+F10 pressed');
end;

it will work. I forgot that there is that message for the system keys :D
0
 
hidrauAuthor Commented:
ok, I misunderstood your post  

I will replace F10 to F12 :))
thanks
0
 
2266180Commented:
no need to. I gave a working solution for F10 just now
0
 
2266180Commented:
I changed
if (msg.message=WM_KEYUP)
to
if (msg.message=WM_SYSKEYUP)

in case you missed the change ;)
0
 
hidrauAuthor Commented:
with (msg.message=WM_SYSKEYUP) , right, because I tested and it worked fine :)))
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now