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. Visual Basic
  4. Catching Control, Shift Key and Alt Key Presses and Releases

Catching Control, Shift Key and Alt Key Presses and Releases

Scheduled Pinned Locked Moved Visual Basic
designhelptutorialquestionannouncement
4 Posts 3 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.
  • J Offline
    J Offline
    Jalapeno Bob
    wrote on last edited by
    #1

    I have been handed an assignment: update a legacy "window" application. The UI must work the same to avoid user re-training costs. The source code is lost/unavailable. (I suspect it was written by a consultant who did not leave the source code. :( ) This legacy code will not run on Win7 or Win10. (Now you see why it must be updated immediately.. :) ) My problem is that the original author "caught" the Shift, Control and Alt keys to select which data frame to display. If none of the three are pressed and held, the most common data is displayed. If the Shift key is pressed and held, the demographics data is displayed. You get the picture. None of these data frames have any interactive controls. The KeyUp, KeyPress, and KeyDown events are not being caught when these keys are pressed:

    Private Sub ucDisplay\_KeyUp(sender As Object, \_
            e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    
        Stop
    
    End Sub
    

    Any suggestions on how to catch these events? Can someone point me to a useful reference? Thank you.

    __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

    A Richard DeemingR 2 Replies Last reply
    0
    • J Jalapeno Bob

      I have been handed an assignment: update a legacy "window" application. The UI must work the same to avoid user re-training costs. The source code is lost/unavailable. (I suspect it was written by a consultant who did not leave the source code. :( ) This legacy code will not run on Win7 or Win10. (Now you see why it must be updated immediately.. :) ) My problem is that the original author "caught" the Shift, Control and Alt keys to select which data frame to display. If none of the three are pressed and held, the most common data is displayed. If the Shift key is pressed and held, the demographics data is displayed. You get the picture. None of these data frames have any interactive controls. The KeyUp, KeyPress, and KeyDown events are not being caught when these keys are pressed:

      Private Sub ucDisplay\_KeyUp(sender As Object, \_
              e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
      
          Stop
      
      End Sub
      

      Any suggestions on how to catch these events? Can someone point me to a useful reference? Thank you.

      __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

      A Offline
      A Offline
      Alex k oShortyo
      wrote on last edited by
      #2

      Private Shiftdown As Boolean = False
      Private altdown As Boolean = False
      Private cntrldown As Boolean = False
      Private Sub ucDisplay_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
      Select Case e.KeyCode
      Case Keys.ShiftKey
      Shiftdown = False
      Case Keys.Menu
      altdown = False
      Case Keys.ControlKey
      cntrldown = False
      End Select
      End Sub
      Private Sub ucDisplay_Keydown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
      Select Case e.KeyCode
      Case Keys.ShiftKey
      Shiftdown = True
      Case Keys.Menu
      altdown = True
      Case Keys.ControlKey
      cntrldown = True
      End Select

          If Shiftdown AndAlso altdown AndAlso cntrldown Then
              'do anything()
          End If
      
      End Sub
      
      1 Reply Last reply
      0
      • J Jalapeno Bob

        I have been handed an assignment: update a legacy "window" application. The UI must work the same to avoid user re-training costs. The source code is lost/unavailable. (I suspect it was written by a consultant who did not leave the source code. :( ) This legacy code will not run on Win7 or Win10. (Now you see why it must be updated immediately.. :) ) My problem is that the original author "caught" the Shift, Control and Alt keys to select which data frame to display. If none of the three are pressed and held, the most common data is displayed. If the Shift key is pressed and held, the demographics data is displayed. You get the picture. None of these data frames have any interactive controls. The KeyUp, KeyPress, and KeyDown events are not being caught when these keys are pressed:

        Private Sub ucDisplay\_KeyUp(sender As Object, \_
                e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        
            Stop
        
        End Sub
        

        Any suggestions on how to catch these events? Can someone point me to a useful reference? Thank you.

        __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        The KeyUp event only fires when the key is released. It sounds like you want to handle the KeyDown event instead.

        Jalapeno Bob wrote:

        The source code is lost/unavailable.

        Is it a .NET application? If so, and if the consultant didn't use an obfuscator, you might be able to use a decompiler to see what the code is doing. It won't give you a perfect copy of the original source, but it might help. Free .NET decompiler :: JetBrains dotPeek[^] JustDecompile .NET Assembly Decompiler & Browser - Telerik[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        J 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          The KeyUp event only fires when the key is released. It sounds like you want to handle the KeyDown event instead.

          Jalapeno Bob wrote:

          The source code is lost/unavailable.

          Is it a .NET application? If so, and if the consultant didn't use an obfuscator, you might be able to use a decompiler to see what the code is doing. It won't give you a perfect copy of the original source, but it might help. Free .NET decompiler :: JetBrains dotPeek[^] JustDecompile .NET Assembly Decompiler & Browser - Telerik[^]


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          J Offline
          J Offline
          Jalapeno Bob
          wrote on last edited by
          #4

          Great Idea!!! Except: Visual Studio shows Intel 80x86 assembly language, not CLR Intermediate language. No symbol table. Just one .exe file. Last compiled in 2001, probably for Win98. Like I said "Legacy code"

          __________________ Lord, grant me the serenity to accept that there are some things I just can’t keep up with, the determination to keep up with the things I must keep up with, and the wisdom to find a good RSS feed from someone who keeps up with what I’d like to, but just don’t have the damn bandwidth to handle right now. © 2009, Rex Hammock

          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