怎样控制form
显示时任务栏不隐藏,并且点WIN键后开始
菜单和任务栏也不弹出! 现在想把FORM做成全屏
显示,在画面运行过程中,不允许进行其他操作。 现在任务栏
不显示好实现,可在画面运行当中点WIN键后,开始
菜单和任务栏会弹出,怎么样能
解决这个问题? 大家帮帮忙,谢谢! __________________________________________________________________________ 我也不是很清楚 提个建议 form里应该有
键盘事件,在
键盘事件中进行限制 __________________________________________________________________________ 不要沉了,不要沉了啊 __________________________________________________________________________ 怎样
屏蔽任务栏和win键 __________________________________________________________________________ 急啊,大家帮帮忙啦 __________________________________________________________________________ 发核心
代码给你 Imports Sy
stem.Runtime.InteropServices Imports Sy
stem.Reflection Public Class SysHook Public Sub New() StartHook() End Sub Protected Overrides Sub Finalize() StopHook() End Sub #Region Define p
arameters Private Declare Function Se
twindowsHookEx Lib user32 Alias Se
twindowsHookExA (ByVal idHook As Integer,ByVal lpfn As HookProc,ByVal hmod As Integer,ByVal dwThreadId As Integer) As Integer Private Declare Function CallNextHookEx Lib user32 Alias CallNextHookEx (ByVal idHook As Integer,ByVal ncode As Integer,ByVal wP
aram As Int32,ByVal lP
aram As IntPtr) As Integer Private Declare Function UnhookWindowsHookEx Lib user32 Alias UnhookWindowsHookEx (ByVal idHook As Integer) As Boolean Private Declare Function GetKeyboardState Lib user32 Alias GetKeyboardState (ByVal pbKeyState As Byte) As Integer Private Declare Function GetKeyState Lib user32 Alias GetKeyState (ByVal nVirtKey As Integer) As Integer Public Delegate Function HookProc(ByVal nCode As Integer,ByVal lP
aram As IntPtr) As Integer Public Event OnMouseActivity As MouseEventHandler Public Event KeyDown As KeyEventHandler Public Event KeyPress As KeyPressEventHandler Public Event KeyUp As KeyEventHandler Dim hMouseHook As Integer = 0 //Declare mouse hook handle as int. Dim hKeyboardHook As Integer = 0 //Declare keyboard hook handle as int. Public Const WH_MOUSE_LL As Integer = 14 //mouse hook constant Public Const WH_KEYBOARD_LL As Integer = 13 //keyboard hook constant Private Const WM_MOUSEMOVE As Integer = &H200 Convert.ToInt32( 0x200,16) Private Const WM_LBUTTONDOWN As Integer = &H201 Private Const WM_RBUTTONDOWN As Integer = &H204 Private Const WM_MBUTTONDOWN As Integer = &H207 Private Const WM_LBUTTONUP As Integer = &H202 Private Const WM_RBUTTONUP As Integer = &H205 Private Const WM_MBUTTONUP As Integer = &H208 Private Const WM_LBUTTONDBLCLK As Integer = &H203 Private Const WM_RBUTTONDBLCLK As Integer = &H206 Private Const WM_MBUTTONDBLCLK As Integer = &H209 Public MouseHookProcedure As HookProc Public KeyboardHookProcedure As HookProc Public Structure Point Public x As Integer Public y As Integer End Structure Public Structure MouseHookStruct Public pt As Point Public hwnd As Integer Public wHitTestCode As Integer Public dwExtraInfo As Integer End Structure Public Structure KeyboardHookStruct Public vkCode As Integer //Specifies a virtual-key code. The code must be a value in the range 1 to 254. Public scanCode As Integer // Specifies a hardware scan code for the key. Public flags As Integer // Specifies the extended-key flag,event-injected flag,context code,and transition-state flag. Public time As Integer // Specifies the time stamp for this message. Public dwExtraInfo As Integer // Specifies extra
information associated with the message. End Structure #End Region Public Sub StartHook() // install Mouse hook If (hMouseHook = 0) Then // Create an instance of HookProc. MouseHookProcedure = New HookProc(AddressOf MouseHookProc) hMouseHook = Se
twindowsHookEx(WH_MOUSE_LL,MouseHookProcedure,Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()(0)).ToInt32,0) //If Se
twindowsHookEx fails. If (hMouseHook = 0) Then StopHook() End If End If // install Keyboard hook If (hKeyboardHook = 0) Then KeyboardHookProcedure = New HookProc(AddressOf KeyboardHookProc) hKeyboardHook = Se
twindowsHookEx(WH_KEYBOARD_LL,KeyboardHookProcedure,0) //If Se
twindowsHookEx fails. If (hKeyboardHook = 0) Then StopHook() End If End If End Sub Public Sub StopHook() Dim retMouse As Boolean = True Dim retKeyboard As Boolean = True If hMouseHook <> 0 Then retMouse = UnhookWindowsHookEx(hMouseHook) hMouseHook = 0 End If If hKeyboardHook <> 0 Then retKeyboard = UnhookWindowsHookEx(hKeyboardHook) hKeyboardHook = 0 End If //If UnhookWindowsHookEx fails. If Not (retMouse And retKeyboard) Then Throw New Exception( UnhookWindowsHookEx
Failed. ) End If End Sub __________________________________________________________________________ Private Function MouseHookProc(ByVal nCode As Integer,ByVal lP
aram As IntPtr) As Integer If (nCode > = 0) And (OnMouseActivityEvent IsNot
nothing) Then Dim button As New MouseButtons button = MouseButtons.None Select Case wP
aram Case WM_LBUTTONDOWN //case WM_LBUTTONUP: //case WM_LBUTTONDBLCLK: button = MouseButtons.Left Case WM_RBUTTONDOWN //case WM_RBUTTONUP: //case WM_RBUTTONDBLCLK: button = MouseButtons.Right End Select Dim clickCount As Integer = 0 If (button <> MouseButtons.None) Then If (wP
aram = WM_LBUTTONDBLCLK Or wP
aram = WM_RBUTTONDBLCLK) Then clickCount = 2 Else clickCount = 1 End If End If //Marshall the data from callback. Dim MyMouseHookStruct As MouseHookStruct MyMouseHookStruct = Marshal.PtrToStructure(lP
aram,GetType(MouseHookStruct)) Dim e As MouseEventArgs e = New MouseEventArgs(button,clickCount,MyMouseHookStruct.pt.x,MyMouseHookStruct.pt.y,0) RaiseEvent OnMouseActivity(Me,e) Dim STPOS As Rectangle STPOS = GetStartPos() If (clickCount > 0) And (MyMouseHookStruct.pt.x > = STPOS.Left) And (MyMouseHookStruct.pt.x <= STPOS.Right) And (MyMouseHookStruct.pt.y > = STPOS.Top) And (MyMouseHookStruct.pt.y <= STPOS.B
ottom) Then A0
startmenu.Show() Return 1 Else If (clickCount > 0) And A0
startmenu.Visible And ((MyMouseHookStruct.pt.x < A0
startmenu.Left) Or (MyMouseHookStruct.pt.x > A0
startmenu.Right) Or (MyMouseHookStruct.pt.y < A0
startmenu.Top) Or (MyMouseHookStruct.pt.y > A0
startmenu.B
ottom)) Then A0
startmenu.Hide() End If Return CallNextHookEx(hMouseHook,nCode,wP
aram,lP
aram) End If End If End Function #Region Define keyboard p
arameters Private Const WM_KEYDOWN As Integer = &H100 0x100 Private Const WM_KEYUP As Integer = &H101 Private Const WM_SYSKEYDOWN As Integer = &H104 Private Const WM_SYSKEYUP As Integer = &H105 #End Region Private Function KeyboardHookProc(ByVal nCode As Integer,ByVal lP
aram As IntPtr) As Integer Dim brk As Boolean If ((nCode > = 0) And (KeyDownEvent IsNot
nothing Or KeyUpEvent IsNot
nothing Or KeyPressEvent IsNot
nothing)) Then Dim MyKeyboardHookStruct As KeyboardHookStruct MyKeyboardHookStruct = Marshal.PtrToStructure(lP
aram,GetType(KeyboardHookStruct)) // raise KeyDown If (KeyDownEvent IsNot
nothing And (wP
aram = WM_KEYDOWN Or wP
aram = WM_SYSKEYDOWN)) Then Dim keyData As Keys keyData = MyKeyboardHookStruct.vkCode Dim e As KeyEventArgs e = New KeyEventArgs(keyData) RaiseEvent KeyDown(Me,e) break the keys -- Win If (e.KeyData = Keys.LWin) Or (e.KeyData = Keys.RWin) Then A0
startmenu.Show() brk = True End If Ctrl+Esc & Alt + Esc If e.KeyData = Keys.Escape And (My.Co
mputer.Keyboard.CtrlKeyDown Or My.Co
mputer.Keyboard.AltKeyDown) Then A0
startmenu.Show() brk = True End If If (e.KeyData = Keys.Escape And Not (My.Co
mputer.Keyboard.CtrlKeyDown Or _ My.Co
mputer.Keyboard.AltKeyDown Or (My.Co
mputer.Keyboard.ShiftKeyDown AndAlso _ My.Co
mputer.Keyboard.CtrlKeyDown))) And A0
startmenu.Focused Then A0
startmenu.Hide() End If Ctrl+Shift+Esc If (e.KeyData = Keys.Escape) AndAlso My.Co
mputer.Keyboard.ShiftKeyDown AndAlso My.Co
mputer.Keyboard.CtrlKeyDown Then A0
startmenu.Show() brk = True End If End If // raise KeyPress If (KeyPressEvent IsNot
nothing And wP
aram = WM_KEYDOWN) Then Dim keyState As Byte GetKeyboardState(keyState) Dim inBuffer As Byte If (ToAscii(MyKeyboardHookStruct.vkCode,MyKeyboardHookStruct.scanCode,keyState,inBuffer,MyKeyboardHookStruct.flags) = 1) Then Dim e1 As KeyPressEventArgs e1 = New KeyPressEventArgs(CChar(CStr(inBuffer))) RaiseEvent KeyPress(Me,e1) End If End If // raise KeyUp If (KeyUpEvent IsNot
nothing And (wP
aram = WM_KEYUP Or wP
aram = WM_SYSKEYUP)) Then Dim keyData As Keys keyData = MyKeyboardHookStruct.vkCode Dim e2 As KeyEventArgs e2 = New KeyEventArgs(keyData) RaiseEvent KeyUp(Me,e2) End If End If If brk Then Return 1 Else Return CallNextHookEx(hKeyboardHook,lP
aram) End If End Function End Class __________________________________________________________________________
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。