Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how i disable ALT+F4 key

how i disable ALT+F4 key

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fgfdhghgfd
    wrote on last edited by
    #1

    hi how can i disable alt+f4 key please give me some clue if possible please send some sample code in c#.

    C 1 Reply Last reply
    0
    • F fgfdhghgfd

      hi how can i disable alt+f4 key please give me some clue if possible please send some sample code in c#.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You might be able to with a system wide keyboard hook. Also, doesn't that close a program ? The onclosing event might be useful, you could write code to refuse to close, unless some condition is met ( such as, ALT is not held down )

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      G P 2 Replies Last reply
      0
      • C Christian Graus

        You might be able to with a system wide keyboard hook. Also, doesn't that close a program ? The onclosing event might be useful, you could write code to refuse to close, unless some condition is met ( such as, ALT is not held down )

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        Have a look at http://www.thescripts.com/forum/thread227955.html

        1 Reply Last reply
        0
        • C Christian Graus

          You might be able to with a system wide keyboard hook. Also, doesn't that close a program ? The onclosing event might be useful, you could write code to refuse to close, unless some condition is met ( such as, ALT is not held down )

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Yeah, that's what I'd suggest.

              private bool closeok = false ;
              
              private void button1\_Click ( object sender , System.EventArgs e )
              {
                  this.closeok = true ;
                  this.Close() ;
              }
          
              private void Form1\_FormClosing ( object sender , System.Windows.Forms.FormClosingEventArgs e )
              {
                   e.Cancel = !closeok ;
              }
          

          The form will only close due to a click of button1. (In addition, if you haven't already, set the form's ControlBox = false;)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups