How Can i disable all windows shortcut keys in vb.net? - vb.net

I want to disable all the windows shortcut keys When my application runs,Please tell me How We can do that in vb.net.Please check my code below.
Public Class Form2
Private Sub Form2_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.Modifiers = Keys.Alt And e.KeyCode = Keys.F4 Then
e.Handled = True
End If
End Sub
End Class

You can disable and enable CTRL+ALT+DEL on demand (at least, you could. I haven't tried this in Windows 7). Take a look at the link below
SystemParametersInfo Function
http://msdn.microsoft.com/en-us/library/ms724947(v=vs.85).aspx
I can see why some people are hesitant to answer this question (and that's why I'm hesitant to post usable lines of code); but I do believe there are legit ways to use this (and clearly, Microsoft agrees because they expose this functionality through their APIs).
I have seen this done in professional/commercial software.
EDIT: I don't know whether or not this approach will disable the other keyboard short-cuts; but it should work for CTRL+ALT+DEL

Related

How to detect a collision in a Windows Store apps?

This is my first question on Stack Overflow's possible that I'll make mistakes. (and I use a internet translator)
I do not know how to detect collision in Windows Store apps. On Windows Forms it looks like this:
If Player.Bounds.IntersectsWith (Enemy1.Bounds) Then
'do something
End If
Please give me function that returns a boolean. Thank you for all the answers.
You can give me c# code i will convert it!
This is just a function with a boolean value as result. You can try this with two simple controls, with buttons for example.
You can create a new project, add two buttons and put them away, then launch the window app, then overlap them and relaunch the app.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Button1.Bounds.IntersectsWith(Button2.Bounds) Then 'this return true/false
MsgBox("Collision detected")
End If
end sub

How do I disable all exiting in Visual Basic

I'm writing an examination piece of software for my workplace and would like to know how I can trap and cancel key-presses such as:
ALT+F4
WIN+TAB
ALT+TAB
WIN
CTRL+ALT+DEL
I'm aware CTRL+ALT+DEL may not be possible, but if any of this is it'll be a step in the right direction!
Ideally I want to prevent the action, and then open a new form I've created saying 'Unauthorised keypress'
as #SQLHound link relates... us the FormClosing event to handle what happens when a user attempts to close. But if you want to block a boot attempt, then #Plutonix suggestion may help. Something along these lines...
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim splashScreen as New Form
splashScreen.OpenDialog
e.Cancel=True
End Sub

Custom hotkey even with unfocused form

I am having a bit problems trying this. I must admit that I am still novice programming. Well, I managed for do this in this way (VB.NET):
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
If My.Computer.Keyboard.CtrlKeyDown Then
MORE IRRELEVANT CODE HERE
End If
End Sub
But with this way, even if it work, it dont let me customice the key shortcut (only Control, shift and others).
I did this too for try differents things:
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = GlobalVariables.own_key Then
MORE IRRELEVANT CODE HERE
End If
End Sub
I give value to GlobalVariables.own_key from other button. This work perfectly, but only if program have the focus.
So... With the first code program work even if it haven't the focus but only with few keys... And with the second it let me use any key, but don't work if it haven't the focus.
I tryed understand the "keyboard hook" but I must admit that I didn't understad it and couldn't manage for work any of them.
Using VB.net 2012.
Really thanks so much for your help
It may not be an answer you like but it is the answer. In .NET, you cannot get notification of keys when your application does not have focus and you cannot get mouse events outside your applications windows. If you looked into the "Keyboard Hook", you should have read that little important fact regarding VB.
Global hooks are not supported in the .NET Framework

Windows button appearance in a VB 2008 application

I am creating a Win32-application in Visual Basic 2008. I would like to have a button in the form, with custom color (BackColor), on MouseEnter event. This works fine, but as you can see below, this custom color doesn't cover the whole area of the button. The button border remains as standard (Windows 7). Can I somehow have this color for the whole button? I don't want to use Flat button style, I prefer this Standard style, which has the normal Windows look.
What I typically do is this I first gather two buttons that look similar, such as this Pic A and B.
Then I will put in those two picture into my Resources.
After I begin coding the function such as the Example I have made down below.
Now their are two ways of going about this. There is a hover option as seen below:
Private Sub PictureBox1_MouseHover(sender As Object, e As EventArgs) Handles PictureBox1.MouseHover
PictureBox1.Image = My.Resources.Button1
End Sub
or there is this option which has way better response times when moving your mouse:
Private Sub PictureBox1_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = My.Resources.Button1
End Sub
Then you need this to set things back to normal:
Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = My.Resources.Button
End Sub
Real simple code but in a realistics thats all you need! I typically hate the buttons! I find myself messing with the button look more then I actually code, really simple to just go to Photoshop and make a easy button that looks good!
I read your Question don't worry but to be honest that style button looks old fashion the buttons I made are more up to date and Modern!

Detect when a user presses CTRL -ALT - DEL or Window + L in VB.net

I'm trying to find out a way to detect when ever the user presses CTRL -ALT - DEL or Window + L to lock the PC.
The code I'm using is
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (GetAsyncKeyState(17) AndAlso GetAsyncKeyState(18) AndAlso GetAsyncKeyState(46)) Or ((GetAsyncKeyState(91) Or GetAsyncKeyState(92)) AndAlso GetAsyncKeyState(76)) Then
Msgbox ("Yes")
End If
End Sub
However, as soon as the user presses CTRL-ALT-DEL the Windows Security Screen comes up and it is too fast for VB to detect that the keys have been pressed.
I did a little reaserch on how to work around this issue and found that a GINA stub can be written which can delay the Windows Security Screen by some time say 2 secs which would be enough for VB to detect that the keys have been pressed.
Also disabling Ctrl-Alt-Del through VB does not work because it is too fast for VB and I would like not to disable CTRL-ALT-DEL
Could some one please let me know how can a GINA stub be created ???
You can find an article about GINA here: Customizing GINA, Part 1
However, Windows Vista and up no longer uses GINA so you'd have to look at Credential Providers, but I'm not sure if they support what you want to do.
I'm not sure exactly what you need to do but I'd suggest that you might want to look at SystemEvents.SessionSwitch in case that might be useful (not used it myself but sounds like a possibility).