Results 1 to 9 of 9

Thread: clipboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    10

    Question

    I have a lot textboxes in my app. Since I don't like to
    check in each if CTRL C was pressed, is there a solution
    for this?

    How can I check on CTRL C, maybe in general without
    orientation to a control?

    thanks
    37.5% of all statistics are made up
    on the spot

  2. #2
    Guest
    You can make an Array of TextBoxes and use the GetKeyState API to determine if they were pressed.

    Code:
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    
    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    
        'If Control and C are pressed then
        If GetKeyState(vbKeyControl) And GetKeyState(vbKeyC) Then
            MsgBox ("Control + C was pressed")
        End If
            
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    10

    Question

    My problem would be more like how can I find out in which
    textbox CTRL C was pressed ?

    (since I have a shortcut defined for the menu entry 'Copy'
    it is easy to handle this)

    37.5% of all statistics are made up
    on the spot

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Megatron,

    Not to question a Guru but wouldn't that code be better in a KeyUp event? Just in case the user is a little slow with the keys. For example, if they hit the Ctrl key first, hold it down, then press C? That event would fire for the Ctrl key before the user got to press the C.



    Just curious...
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5
    Guest
    Not in this case. Because we are using the GetKeyState API, it will only trigger when both keys are pressed at the same time.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    10
    but gyus, back to my problem, thanks. How in general is it
    possible to identify the control which triggered an event?
    37.5% of all statistics are made up
    on the spot

  7. #7
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Thank you. I'm still reading Appleman's API book, I just finished with chapter 2. So the API is still a foreign language to me.



    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  8. #8
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    How about using a public variable and set it to the index value inside the procedure Megatron just posted. This way you can check this variable to see which textbox it was.



    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  9. #9
    Guest
    Try this.

    Code:
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    
    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    
        'If Control and C are pressed then
        If GetKeyState(vbKeyControl) And GetKeyState(vbKeyC) Then
            MsgBox ("Control + C was pressed in Text1(" & Index & ")")
        End If
            
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width