|
-
May 3rd, 2001, 12:32 AM
#1
Thread Starter
Junior Member
Pls help..How to disable "Print Scrn" button in VB application
Hello,
New to VB. I have a VB application. When the user is using this application, I would like to disable the usage of "Print Scrn" button. I mean if the user hits the "Print Scrn" button, he should not be able to capture the screen shots in the buffer. In the Form_Keypress event, I tried to capture the ascii value of the button. But I can capture all other buttons except "esc" "F1 F21", "Print Screen", "Scroll Lock", "Pause" buttons.
Can someone point me the right direction..
thank you
nath
-
May 3rd, 2001, 12:38 AM
#2
Addicted Member
You can trap the keycode in Form_KeyUp
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub
will return 44
-
May 3rd, 2001, 12:44 AM
#3
Addicted Member
..or
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 44 or KeyCode = 106 Then
Clipboard.Clear
End If
End Sub
-
May 3rd, 2001, 01:07 AM
#4
PowerPoster
Code:
Private Declare Function GetAsyncKeyState _
Lib "user32.dll" (ByVal vKey As Long) As Integer
Private Const VK_MENU = &H12 'either alt key
Private Const VK_SNAPSHOT = &H2C 'print screen
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If GetAsyncKeyState(VK_MENU) Then
MsgBox "Alt key pressed"
ElseIf GetAsyncKeyState(VK_SNAPSHOT) Then
MsgBox "Print screen key pressed"
End If
End Sub
-
May 3rd, 2001, 11:26 AM
#5
Thread Starter
Junior Member
Thankx to both of you..but..
Thanks to you all. It works fine. As long my screen/form is active and if the user hits Print Screen button, the code works.
But when the user shrinks my VB application (I mean the screen/form which has code) and is viewing other applications on the desktop and if hits the print screen button, he will get my VB Screen (which is shinked in size) and other application into the clipboard. How can I avoid this scenario.
Could someone point me right direction please...
thank you friends.
nath
-
May 4th, 2001, 12:31 AM
#6
Addicted Member
When your application looses focus the control goes to Windows or another application on top. I do not know if windows can be configured to avoid printscreen. Someone pls help..
-
May 5th, 2001, 08:51 AM
#7
PowerPoster
You will have to use system hook, but I am afraid its not possible in VB as it needs a standard dll to work(not an activex dll that is created using VB)
-
May 5th, 2001, 01:22 PM
#8
Fanatic Member
You don't need to use a system hook this simple code should do the trick and will work regardless of whether or not your app has focus...
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Const VK_PRNTSCRN = &H2C
Private Sub Form_Load()
Me.Show
Do Until DoEvents = 0
If Not GetAsyncKeyState(VK_PRNTSCRN) = 0 Then
OpenClipboard Me.hwnd
EmptyClipboard
CloseClipboard
End If
Loop
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
May 7th, 2001, 09:46 PM
#9
Thread Starter
Junior Member
Is it possible in a Browser
Hello my friend
Your piece of code works in VB .
Thank you for that.
Is it possible to implement same solution in a Browser?
thank you
bnath001
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|