Results 1 to 5 of 5

Thread: Copying to Clipboard through Toolbar

  1. #1

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Copying to Clipboard through Toolbar

    I´m using this code:

    VB Code:
    1. Public Sub submnuCopy_Click()
    2.     Clipboard.Clear
    3.     If TypeOf Screen.ActiveControl Is TextBox Then
    4.         Clipboard.SetText Screen.ActiveControl.SelText
    5.     ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    6.         Clipboard.SetText Screen.ActiveControl.Text
    7.     ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
    8.         Clipboard.SetData Screen.ActiveControl.Picture
    9.     ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    10.         Clipboard.SetText Screen.ActiveControl.Text
    11.     Else
    12.       ' No action makes sense for the other controls.
    13.     End If
    14.  
    15. End Sub

    How do I do to make it work through a Toolbar. The problem is that if I click on the Copy button, I'm getting that the Screen.ActiveControl is set to nothing. How do I change this?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Boy, that is a problem. What if you tried setting an Object variable in the ToolBar_MouseMove event. That event would fire before the active control lost focus.

    You might then be able to do It TypeOf ObjectVar is TextBox Then...

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Thanks, Greg... that was the kind of trick I was thinking. I was wondering if it existed a more "nice" way for doin' it... but, WHATEVER!!

    FYI (Just to comment it) I also need a boolean variable to avoid the MouseMove Event set this variable once I pressed the button, and reset this boolean after it.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Cool!

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  5. #5
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    I've seen this solved before by keeping a public variable containing the name of the last control that has focus, then you read from that, and use that to decide what control it is
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

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