C#如何锁定屏幕
我在用C#编一个电路软件,我现在做的就是单击一个器件,比如说是变压器,我一单击,就会出现一个记录这个变压器信息的界面,以上是背景,问题是我想在我输入信息的时候,屏幕能够锁定在这个输入信息的界面上,我在网上找的,有些高人说可以通过调用API中的LockWindow实现,请问具体怎么实现,或者还有什么方法能实现,具体点 谢谢
2011-10-25 14:37
程序代码:public class Win32Hook
{
[DllImport("kernel32")]
public static extern int GetCurrentThreadId();
[DllImport( "user32",
CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx(
HookType idHook,
HOOKPROC lpfn,
int hmod,
int dwThreadId);
public enum HookType
{
WH_GETMESSAGE = 3
}
public delegate int HOOKPROC(int nCode, int wParam, int lParam);
public void SetHook()
{
// set the keyboard hook
SetWindowsHookEx(HookType.WH_GETMESSAGE,
new HOOKPROC(this.MyKeyboardProc),
0,
GetCurrentThreadId());
}
public int MyKeyboardProc(int nCode, int wParam, int lParam)
{
//Perform your process
return 0;
}
}
Win32Hook hook = new Win32Hook();
hook.SetHook();

2011-10-25 17:24
.
2011-10-25 17:48
2011-10-26 09:26