Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2006, 10:17 AM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Michael Eaton
Default print screen key

Would it be possible to attach an event to a user pressing the printscreen button?

Thanks!

Michael

---------------------

Thanks for all your help P2P Wrox! (and its users)
 
Old September 22nd, 2006, 12:18 PM
Authorized User
 
Join Date: Sep 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael,

Try adding the following code to the desired form...

    protected override void OnKeyUp(KeyEventArgs e)
    {
      if (e.KeyCode == Keys.PrintScreen)
      {
        System.Diagnostics.Debug.WriteLine(
          string.Format("PrintScreen key released at {0}.",
          DateTime.Now));

        // This next statement is optional. Include it to tell
        // windows that you have taken all action that should be
        // taken in response to this key press. If you want Windows
        // to also perform its default handling, then do not include
        // this next statement.

        e.Handled = true;
      }

      base.OnKeyUp(e);
    }

- Roger
 
Old September 22nd, 2006, 01:19 PM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Michael Eaton
Default

Roger:

First of all, thanks for the reply... it works great -- when the form is the active window.. but i plan to not use a window at all, and only run in systray/formless (at least for the main form) so it would proberly need to always listen for the print screen key, even when the application is in the background (which in my case will be all the time.. as there isnt a front-end)

Hope that makes sense :)

Thanks!

Michael

---------------------

Thanks for all your help P2P Wrox! (and its users)
 
Old September 22nd, 2006, 01:28 PM
Authorized User
 
Join Date: Sep 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael,

Sounds like you need a hook into the message queues of all active windows (since you'll never know in advance which window will be active when the user presses print screen). That, unfortunately, is beyond my current level of expertise.

- Roger
 
Old September 22nd, 2006, 01:29 PM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Michael Eaton
Default

Thats a shame.. Thanks for your help though.

---------------------

Thanks for all your help P2P Wrox! (and its users)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Press Print Screen Key Using JavaScript sundar53 .NET Framework 2.0 0 November 4th, 2007 08:48 AM
print screen jasonsjones Visual Basic 2005 Basics 1 May 21st, 2007 06:37 AM
Form Screen drifts when closing print preview toddw607 Access 5 February 27th, 2007 09:23 AM
Disable print screen Steve777 Javascript 13 February 16th, 2006 08:44 AM
PRINT SCREEN key.. Jayahar C# 0 December 21st, 2005 03:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.