[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

disable print screen

Posted on 1997-07-24
5
Medium Priority
?
318 Views
Last Modified: 2008-03-17
I am trying to find a way within VB to disable the print screen key within my application.  I have secure information displayed and I don't want users to be able use the print screen key and then go into another application and paste and print information.  I only want this to be for this application and I don't want to disable the cut and paste for other applications they may have running.  Any ideas?
0
Comment
Question by:lilaudrey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:ChrisLewis
ID: 1428840
You cannot disable the printscreen key in VB, but here's the start of a work around.

You can try this to start.

In a form with Keypreview set to TRUE...

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  Debug.Print "UP:" & KeyCode
  If KeyCode = vbKeyPrint Or vbKeySnapshot Then
    Clipboard.Clear
    MsgBox "No Print Screens!"
  End If

End Sub

This doesn't eliminate the printScreen, just immediately clears the copy buffer.  This, however, has some problems.  It only works if your form has focus.  If it's visible in the background, PrintScreen will still work.

Ways around this include minimizing the form when it looses forcus,  and also setting the form on top always.

To minimize on non use, try this.

Set a timer  in the form, with the following code. (interval real low - 2 or 3 based on processing needs)  

Private Sub Timer1_Timer()
  DoEvents
  Select Case apiGetFocus()
    Case Me.hWnd
    Case Text1.hWnd
    Case Text2.hWnd
    Case Command1.hWnd
    Case Else
      Me.WindowState = vbMinimized
  End Select
End Sub
You will have to put a line for each control on your form!

Ad a declare in a module:
Declare Function apiGetFocus Lib "user32" Alias "GetFocus" () As Long

This should work, even though it's kinda clunky

Hope this helps

Chris
0
 

Author Comment

by:lilaudrey
ID: 1428841
The first part works great, however the part on minimizing when it looses focus does not work.  Could this have something to do with the fact that we are using 16 bit VB instead of 32.  It bombs using your method on some DLL file.  I need both parts to work if I am to use this solution.    Thanks
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 300 total points
ID: 1428842
Yup, Would definately bomb in the 16 bit world.  For the 16 bit world, use the following API call:

Declare Function GetFocus Lib "User" Alias apiGetFocus () as Integer

Hope this helps

Chris
0
 

Author Comment

by:lilaudrey
ID: 1428843
Thanks,  I will try that and let you know if it works.  I agree it is sort of a weird solution but if it works it will be a great help in solving my security problem and will allow us to implement.
0
 

Author Comment

by:lilaudrey
ID: 1428844
Chris,
This doesn't seem to work either.  I do not have a user.dll.  Is this  my problem and if so could you send me one at acampbell @ppg.com
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question