Solved

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

Posted on 2006-11-29
9
428 Views
Last Modified: 2010-04-05
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
Comment
Question by:hidrau
  • 5
  • 4
9 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 18036508
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
 
LVL 1

Author Comment

by:hidrau
ID: 18036569
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
 
LVL 1

Author Comment

by:hidrau
ID: 18036584
What does this "handled : Boolean" in the function serve for?

0
 
LVL 1

Author Comment

by:hidrau
ID: 18036608
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
ID: 18036626
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
 
LVL 1

Author Comment

by:hidrau
ID: 18036640
ok, I misunderstood your post  

I will replace F10 to F12 :))
thanks
0
 
LVL 28

Expert Comment

by:ciuly
ID: 18036657
no need to. I gave a working solution for F10 just now
0
 
LVL 28

Expert Comment

by:ciuly
ID: 18036660
I changed
if (msg.message=WM_KEYUP)
to
if (msg.message=WM_SYSKEYUP)

in case you missed the change ;)
0
 
LVL 1

Author Comment

by:hidrau
ID: 18036664
with (msg.message=WM_SYSKEYUP) , right, because I tested and it worked fine :)))
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now