Results 1 to 9 of 9

Thread: cut, copy, paste, help and other newbie stuff

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Smile

    Hi guys!

    I want to add an "Edit" menu in my menu bar of my application. I just want to add basic stuff like cut, copy, paste, and maybe undo too. All my controls are textboxes and combos, so i'll just be cutting and pasting strings and text. How do I go about implementing this?

    Also, I want to add a "Help" menu, how do I make those standard help files in most windows applications?


    Thanks in advance for all the help

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    I use the following for Select All, Cut, Copy and Paste.

    Code:
    Private Sub mnuSelectAll_Click()
        rtfData.SelStart = 0
        rtfData.SelLength = Len(rtfData.text)
        rtfData.SetFocus
    End Sub
    Private Sub mnuFileCut_Click()
       Clipboard.Clear
       Clipboard.SetText rtfData.SelText
       rtfData.SelText = ""
       rtfData.SetFocus
    End Sub
    
    Private Sub mnuFileCopy_Click()
      Clipboard.Clear
      Clipboard.SetText rtfData.SelText
      rtfData.SetFocus
    End Sub
    
    Private Sub mnuFilePaste_Click()
       rtfData.SelText = Clipboard.GetText()
       rtfData.SetFocus
    End Sub
    The Clipboard object is shared by all Windows applications, so you do not need to declare it in VB.

    I found code for UNDO in this forum before. It involves setting up an array to store the keystroke changes.

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Look at this link:

    http://www.planet-source-code.com/xq...s/ShowCode.htm

    for some ideas.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74
    Thanks now i know about the clipboard stuff, but the code only works if i only have one text box. I have different controls and textboxes in my application. How do I apply it to all?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Thanks jbart

    Nevermind I figured it out already! Thanks jbart for pointing me to the right direction, you were a great help

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74
    just wondering, is there a nifty way of keeping track if there is something in the clipboard? I want the paste to be enabled only if there is something in the clipboard. Anyone know a way to do this?

  7. #7
    Guest
    To keep track, paste the contents of the clipboard into a variable:

    Code:
         Dim ClipData As String
         ClipData = Clipboard.GetText()
         If ClipData <> "" Then
              Msgbox "Data on clipboard!"
         Else
              Msgbox "No data on clipboard!"
         End If

  8. #8
    Guest
    When working with a RichTextBox, you should use the flag vbCFRTF to store and paste the data in RichText Format.
    Code:
    Private Sub mnuSelectAll_Click()
        rtfData.SelStart = 0
        rtfData.SelLength = Len(rtfData.Text)
        rtfData.SetFocus
    End Sub
    Private Sub mnuFileCut_Click()
        Clipboard.Clear
        Clipboard.SetText rtfData.SelText, vbCFRTF
        rtfData.SelText = ""
        rtfData.SetFocus
    End Sub
    
    Private Sub mnuFileCopy_Click()
        Clipboard.Clear
        Clipboard.SetText rtfData.SelText, vbCFRTF
        rtfData.SetFocus
    End Sub
    
    Private Sub mnuFilePaste_Click()
        rtfData.SelText = Clipboard.GetText(vbCFRTF)
        rtfData.SetFocus
    End Sub

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Talking

    This is great I always learn something new! Thanks guys! Now all I need is to make a nifty help file, does anyone know where I can get started? Been looking for a tutorial but can't seem to find one, I must suck at this



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