Click here to Skip to main content
15,888,330 members
Home / Discussions / C#
   

C#

 
QuestionHow to count the jobs shown in the taskbar and get their names (or texts)? Pin
bihshan.lin3-Oct-05 5:46
bihshan.lin3-Oct-05 5:46 
QuestionAborting Threads Pin
NitinR3-Oct-05 5:37
NitinR3-Oct-05 5:37 
AnswerRe: Aborting Threads Pin
S. Senthil Kumar3-Oct-05 18:58
S. Senthil Kumar3-Oct-05 18:58 
GeneralRe: Aborting Threads Pin
NitinR5-Oct-05 8:22
NitinR5-Oct-05 8:22 
Questionhelp req for interoperatibility Pin
arusmemon3-Oct-05 4:50
arusmemon3-Oct-05 4:50 
QuestionMissing operator message Pin
zaboboa3-Oct-05 4:39
zaboboa3-Oct-05 4:39 
AnswerRe: Missing operator message Pin
Guffa3-Oct-05 14:23
Guffa3-Oct-05 14:23 
QuestionQuestion about keyboard(be patience for answer this #@$%% question) Pin
Alex Cutovoi3-Oct-05 4:27
Alex Cutovoi3-Oct-05 4:27 
Hi for all

I've readed the Dominique Bijnens' article "Background applications listening for keyboard activity" that explains how to read the keyboard even in background. There are some pieces of code that I didn't understand. Dominique explains that the KeyHandler function will be called when a key is pressed of the keyboard. What I didn't understand is when and where the static constructor of the KeyboardListener class is called. Below some pieces of code of their article.
Please, who have a little(or a lot) bit of patience answer this question for me.

Thanks a lot for help

private static void KeyHandler(ushort key, uint msg)
{
if(s_KeyEventHandler != null)
{
Delegate[] delegates = s_KeyEventHandler.GetInvocationList();

foreach(Delegate del in delegates)
{
EventHandler sink = (EventHandler)del;

try
{
// This is a static class, therefore null is passed as the object reference
sink(null,new UniversalKeyEventArgs(key,msg));
}

// You can add some meaningful code to this catch block.
catch{};
}
}
}
#endregion

#region Public declarations

///
/// An instance of this class is passed when Keyboard events are fired by the KeyboardListener.
///

public class UniversalKeyEventArgs : KeyEventArgs
{
public readonly uint m_Msg;
public readonly ushort m_Key;

public UniversalKeyEventArgs(ushort aKey, uint aMsg) : base((Keys)aKey)
{
m_Msg = aMsg;
m_Key = aKey;
}
}

///
/// For every application thread that is interested in keyboard events
/// an EventHandler can be added to this variable
///

public static event EventHandler s_KeyEventHandler;

#endregion

#region Public methods

static KeyboardListener()
{
ListeningWindow.KeyDelegate aKeyDelegate = new ListeningWindow.KeyDelegate(KeyHandler);
s_Listener = new ListeningWindow(aKeyDelegate);
}
AnswerRe: Question about keyboard(be patience for answer this #@$%% question) Pin
Robert Rohde3-Oct-05 7:13
Robert Rohde3-Oct-05 7:13 
GeneralRe: Question about keyboard(be patience for answer this #@$%% question) Pin
Alex Cutovoi3-Oct-05 8:32
Alex Cutovoi3-Oct-05 8:32 
QuestionDateTimeFormatInfo.Calendar problem Pin
Leyu3-Oct-05 4:23
Leyu3-Oct-05 4:23 
QuestionConverting Strings to Hex Pin
Guinness4Strength3-Oct-05 4:11
Guinness4Strength3-Oct-05 4:11 
AnswerRe: Converting Strings to Hex Pin
Martin#3-Oct-05 4:23
Martin#3-Oct-05 4:23 
GeneralRe: Converting Strings to Hex Pin
Guinness4Strength3-Oct-05 4:27
Guinness4Strength3-Oct-05 4:27 
GeneralRe: Converting Strings to Hex Pin
Dan Neely3-Oct-05 4:46
Dan Neely3-Oct-05 4:46 
GeneralRe: Converting Strings to Hex Pin
Guinness4Strength3-Oct-05 4:55
Guinness4Strength3-Oct-05 4:55 
GeneralRe: Converting Strings to Hex Pin
Dan Neely3-Oct-05 6:53
Dan Neely3-Oct-05 6:53 
GeneralRe: Converting Strings to Hex Pin
Guinness4Strength3-Oct-05 8:44
Guinness4Strength3-Oct-05 8:44 
AnswerRe: Converting Strings to Hex Pin
Dario Solera3-Oct-05 7:06
Dario Solera3-Oct-05 7:06 
GeneralRe: Converting Strings to Hex Pin
Guinness4Strength3-Oct-05 8:43
Guinness4Strength3-Oct-05 8:43 
GeneralRe: Converting Strings to Hex Pin
Dario Solera3-Oct-05 9:08
Dario Solera3-Oct-05 9:08 
GeneralRe: Converting Strings to Hex Pin
Guinness4Strength3-Oct-05 9:12
Guinness4Strength3-Oct-05 9:12 
GeneralRe: Converting Strings to Hex Pin
Dario Solera4-Oct-05 5:25
Dario Solera4-Oct-05 5:25 
QuestionISerializable problems Pin
g00fyman3-Oct-05 3:53
g00fyman3-Oct-05 3:53 
AnswerRe: ISerializable problems Pin
Robert Rohde3-Oct-05 7:27
Robert Rohde3-Oct-05 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.