Click here to Skip to main content
15,921,577 members
Home / Discussions / C#
   

C#

 
GeneralRe: String output in C# from a C++ dll Pin
vinayakdl5-Jan-05 4:53
vinayakdl5-Jan-05 4:53 
GeneralRe: String output in C# from a C++ dll Pin
Heath Stewart5-Jan-05 7:04
protectorHeath Stewart5-Jan-05 7:04 
GeneralRe: String output in C# from a C++ dll Pin
vinayakdl6-Jan-05 9:55
vinayakdl6-Jan-05 9:55 
GeneralRe: String output in C# from a C++ dll Pin
Heath Stewart6-Jan-05 12:04
protectorHeath Stewart6-Jan-05 12:04 
GeneralHELP! Web secuirty ... Pin
mrwonkothesane424-Jan-05 11:38
mrwonkothesane424-Jan-05 11:38 
GeneralReplacing text Pin
Christer Claesson4-Jan-05 11:35
Christer Claesson4-Jan-05 11:35 
GeneralSpecial Keyboard keys Pin
BertGo4-Jan-05 10:25
BertGo4-Jan-05 10:25 
GeneralRe: Special Keyboard keys Pin
Heath Stewart4-Jan-05 11:12
protectorHeath Stewart4-Jan-05 11:12 
The OEM keys (original equipment manufacturer) are supported through the KeyEventArgs.KeyData property when you override OnKeyDown (best when extending classes in which the keys are handled) or handle the KeyDown event. See the property documentation in the .NET Framework SDK for more details.

Compile the following example:
//#!csc.exe /t:winexe Test.cs
//
 
using System;
using System.Drawing;
using System.Windows.Forms;
 
class Test : Form
{
  static void Main()
  {
    Application.Run(new Test());
  }
 
  TextBox tb;
 
  Test()
  {
    tb = new TextBox();
    Controls.Add(tb);
    tb.Multiline = true;
    tb.Dock = DockStyle.Fill;
 
    Text = "Press any key";
    KeyPreview = true;
  }
 
  protected override void OnKeyDown(KeyEventArgs e)
  {
    AddLine(e.KeyData);
    base.OnKeyDown(e);
  }
 
  void AddLine(Keys keys)
  {
    tb.AppendText(keys.ToString() + Environment.NewLine);
  }
}
With keys there really isn't much reason to require P/Invoke, though P/Invoking the native GetKeyState or GetAsyncKeyState APIs can be helpful for toggle keys that wouldn't be in KeyEventArgs.Modifiers.

For more information on P/Invoke (Platform Invoke), read Consuming Unmanaged DLL Functions[^] and Marshaling Data with Platform Invoke[^] in the .NET Framework SDK.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: Special Keyboard keys Pin
BertGo4-Jan-05 13:00
BertGo4-Jan-05 13:00 
GeneralRe: Special Keyboard keys Pin
Heath Stewart4-Jan-05 13:29
protectorHeath Stewart4-Jan-05 13:29 
Generalstopping service via WMI Pin
thespiff4-Jan-05 8:36
thespiff4-Jan-05 8:36 
GeneralRe: stopping service via WMI Pin
Heath Stewart4-Jan-05 10:51
protectorHeath Stewart4-Jan-05 10:51 
GeneralRe: stopping service via WMI Pin
thespiff5-Jan-05 1:03
thespiff5-Jan-05 1:03 
GeneralRe: stopping service via WMI Pin
Heath Stewart5-Jan-05 4:50
protectorHeath Stewart5-Jan-05 4:50 
GeneralRe: stopping service via WMI Pin
thespiff6-Jan-05 2:19
thespiff6-Jan-05 2:19 
GeneralImplementing mouse panning functionality Pin
Andres Coder4-Jan-05 7:55
Andres Coder4-Jan-05 7:55 
GeneralRe: Implementing mouse panning functionality Pin
Heath Stewart4-Jan-05 11:30
protectorHeath Stewart4-Jan-05 11:30 
GeneralIs this acceptable practice Pin
Wayne Phipps4-Jan-05 7:54
Wayne Phipps4-Jan-05 7:54 
GeneralRe: Is this acceptable practice Pin
perlmunger4-Jan-05 8:41
perlmunger4-Jan-05 8:41 
QuestionHow To Serialize Multiples Refereces to The Same Object? Pin
fmarcos4-Jan-05 7:18
fmarcos4-Jan-05 7:18 
AnswerRe: How To Serialize Multiples Refereces to The Same Object? Pin
Matt Gerrans4-Jan-05 8:03
Matt Gerrans4-Jan-05 8:03 
GeneralLaunching Forms Dynamically Pin
SignMan3594-Jan-05 6:14
SignMan3594-Jan-05 6:14 
GeneralRe: Launching Forms Dynamically Pin
Nick Parker4-Jan-05 7:23
protectorNick Parker4-Jan-05 7:23 
GeneralRe: Launching Forms Dynamically Pin
SignMan3594-Jan-05 14:28
SignMan3594-Jan-05 14:28 
GeneralRe: Launching Forms Dynamically Pin
Anonymous5-Jan-05 4:01
Anonymous5-Jan-05 4:01 

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.