Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
Generalinterop struct types Pin
Tym!17-Sep-03 2:59
Tym!17-Sep-03 2:59 
GeneralMarshaling Structs Reference Pin
Tym!17-Sep-03 4:26
Tym!17-Sep-03 4:26 
GeneralEditable ListView items Pin
Rickard Andersson2017-Sep-03 1:28
Rickard Andersson2017-Sep-03 1:28 
GeneralRe: Editable ListView items Pin
JoeGunchy17-Sep-03 9:22
JoeGunchy17-Sep-03 9:22 
GeneralRe: Editable ListView items Pin
Rickard Andersson2017-Sep-03 10:46
Rickard Andersson2017-Sep-03 10:46 
GeneralWindows service, OnShutDown not executed Pin
EnkelIk16-Sep-03 23:18
EnkelIk16-Sep-03 23:18 
GeneralRe: Windows service, OnShutDown not executed Pin
EnkelIk16-Sep-03 23:36
EnkelIk16-Sep-03 23:36 
GeneralKeyboard hooks - Problem Pin
CyberKewl16-Sep-03 22:21
CyberKewl16-Sep-03 22:21 
I have a problem with keyboard hooks - every time i press hold the CTRL+SHIFT key for quite some time, my application will crash with the error message :

"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object."

I've searched high and low for a solution to this matter but to no avail. Here's the code that i am using, it is meant to disable keys like ALT+TAB, CTRL+ESC, etc:

protected delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);

[ DllImport( "user32.dll", EntryPoint="SetWindowsHookExA", CharSet=CharSet.Ansi )]

protected static extern int SetWindowsHookEx(int idHook , LowLevelKeyboardProcDelegate lpfn, int hMod , int dwThreadId);

[ DllImport( "user32.dll")]
protected static extern int CallNextHookEx(int hHook,int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);

[ DllImport("user32.dll")]
protected static extern int UnhookWindowsHookEx(long hhook);

const int WH_KEYBOARD_LL = 13;
public struct KBDLLHOOKSTRUCT
{
public int vkCode;
int scanCode;
public int flags;
int time;
int dwExtraInfo;
}
protected int intLLKey = 0;

protected int LowLevelKeyboardProc(int nCode,int wParam,ref KBDLLHOOKSTRUCT lParam)
{
bool blnEat = false;

switch (wParam)
{
case 256:
case 257:
case 260:
case 261:
//Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
if (((lParam.vkCode == 9) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 0))
|| ((lParam.vkCode == 91) && (lParam.flags == 1))
|| ((lParam.vkCode == 92) && (lParam.flags == 1))
|| ((true) && (lParam.flags == 32)))

{
blnEat = true;
}
break;
}
if (blnEat)
return 1;
else
{
return CallNextHookEx(0, nCode, wParam, ref lParam);
}
}
public void KeyboardHook()
{
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc), System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(),0);
}

Generalunicode in c# Pin
Anonymous16-Sep-03 21:13
Anonymous16-Sep-03 21:13 
GeneralRe: unicode in c# Pin
Oleksandr Kucherenko17-Sep-03 0:02
Oleksandr Kucherenko17-Sep-03 0:02 
GeneralOne ScrollBar controls two DataViews Pin
JoeGunchy16-Sep-03 14:40
JoeGunchy16-Sep-03 14:40 
GeneralC# is the best Pin
Snyp16-Sep-03 12:13
Snyp16-Sep-03 12:13 
GeneralRe: C# is the best Pin
Rickard Andersson2017-Sep-03 1:30
Rickard Andersson2017-Sep-03 1:30 
GeneralRe: C# is the best Pin
Snyp17-Sep-03 1:42
Snyp17-Sep-03 1:42 
GeneralRe: C# is the best Pin
Rickard Andersson2017-Sep-03 2:42
Rickard Andersson2017-Sep-03 2:42 
GeneralRe: C# is the best Pin
Snyp17-Sep-03 11:06
Snyp17-Sep-03 11:06 
GeneralRe: C# is the best Pin
Rickard Andersson2017-Sep-03 21:53
Rickard Andersson2017-Sep-03 21:53 
GeneralRe: C# is the best Pin
Snyp18-Sep-03 10:46
Snyp18-Sep-03 10:46 
GeneralEmbed WindowsMediaPlayer Problem Pin
pahluwalia16-Sep-03 11:46
pahluwalia16-Sep-03 11:46 
GeneralSimple/Stupid Casting Question Pin
MKlucher16-Sep-03 11:13
MKlucher16-Sep-03 11:13 
GeneralRe: Simple/Stupid Casting Question Pin
Travis D. Mathison16-Sep-03 11:43
Travis D. Mathison16-Sep-03 11:43 
GeneralRe: Simple/Stupid Casting Question Pin
Braulio Dez16-Sep-03 21:04
Braulio Dez16-Sep-03 21:04 
GeneralReEdit Data freezes Controls; No Edition possible Pin
STW16-Sep-03 11:01
STW16-Sep-03 11:01 
QuestionHOW TO SPREAD TEXT OVER COLUMNS IN A LISTVIEW IN C# Pin
ARTURO CAJINA16-Sep-03 9:57
ARTURO CAJINA16-Sep-03 9:57 
AnswerRe: HOW TO SPREAD TEXT OVER COLUMNS IN A LISTVIEW IN C# Pin
Alvaro Mendez17-Sep-03 5:58
Alvaro Mendez17-Sep-03 5:58 

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.