Results 1 to 7 of 7

Thread: edit, copy, cut, undo

  1. #1

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    anyone know the code for those using a rich textbox?

  2. #2
    Guest
    To use them, set the RichTextBox's AutoVerbMenu property to True.

  3. #3

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    yes but i have a menu with those options ... i want the code for them ...

  4. #4
    Guest
    Copy


    Code:
    Clipboard.Clear
    Clipboard.SetText RichTextBox1.SelText

    Cut


    Code:
    Clipboard.Clear
    Clipboard.SetText RichTextBox1.SelText
    RichTextBox1.SelText = ""

    Paste


    Code:
    RichTextBox1.SelText = Clipboard.GetText()

    Undo


    Code:
    Private Declare Function SendMessage _
    Lib "user32" Alias "SendMessageA" (ByVal hwnd As _
    Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long
    
    Private Const WM_UNDO = &H304
    
    
    Private Sub Command1_Click()
        SendMessage RichTextBox1.hwnd, WM_UNDO, 0, 0
    End Sub

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The RTB also has built in the shortcuts CTRL+(X, C, V, and Z) for this.
    I noticed that if you use the Clipboard object in code to cut the selected text you can't undo that by pressing CTRL+Z.
    What you can do is simply sending the right key combination to the RTB with the help of SendKeys.

    Best regards

  6. #6

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    thanks matt ...

    Joacim Andersson i first tried coding it that way ... i love sendkeys but one thing that makes me not use them is that for some reason it turns my NumLock light on and off ... don't know why but it just does ...

  7. #7
    Guest
    The following messages can also be sent
    Code:
    Private Const WM_CUT = &H300
    Private Const WM_COPY = &H301
    Private Const WM_PASTE = &H302

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