Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Dear All,

As I'm developing the application in VB.net. I want to define my function Key as Global during all the Application working i.e F1 as help key, F2 as Customer Combo, F3 as Invoice Detail and so on. As I define all the key in MDI Parent Form but it function in the MDI form Only not in the rest of the program.

Pl guide.

Thanks,

Jatin gupta.
Posted
Updated 28-Aug-10 22:53pm
v2
Comments
Keith Barrow 29-Aug-10 4:54am    
[Edit]: I changed the title, the original looked like a asymmetric encryption question.

1 solution

AFAIK there is no "simple" way to do this, but it is possible.

Method 1- Windows Message Queue
Complicated and more difficult to maintain/understand, but this has the advantage of "being in one place". Here is a reference
MSDN Windows Message and Message Queues[^]

  • Hook into the windows queue from the main form
  • Catch all Function key presses for the current application from the queue (don't forget to handle!)


Method 2- Custom Window Class

Simpler, but but code spread around.

  • Sublcass a form and add an event that fires when a function key is pressed (passing the key number
  • In the subclassed form hook up the function keys so they call the event in the above step
  • In the subclass, automatically subscribe into created child form's Function key event, and re-raise if child form fires
  • Derive all forms from the subclass
  • In the main [root] form, subscribe into the top function key event and put the desired functionality into the handling method


Hopefully, someone else might have worked out a better solution, in WPF what you ask for would be a doddle.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900