Results 1 to 2 of 2

Thread: undo and redo

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    undo and redo

    hi, i have a richtext box but the only part im not sure on how to code is the "undo" and "redo" options the save as and the print (well i can do the print but im not sure if its right)
    how would i do those options?

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: undo and redo

    To undo and redo
    Code:
    Private Const WM_USER As Long = &H400
    Private Const EM_UNDO As Long = &HC7
    Private Const EM_REDO As Long = (WM_USER + 84)
    Private Const EM_CANREDO As Long = (WM_USER + 85)
    Private Const EM_CANUNDO As Long = &HC6
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    
    Private Sub Command1_Click()    'Undo
        SendMessage RichTextBox1.hwnd, EM_UNDO, 0, 0&
    End Sub
    
    Private Sub Command2_Click()    'Redo
        SendMessage RichTextBox1.hwnd, EM_REDO, 0, 0&
    End Sub
    
    Private Sub Form_Load()
        'Set the command button status'
        
        'This can be replaced by setting command1 and command2, enabled = false ;)
        RichTextBox1_Change
    End Sub
    
    Private Sub RichTextBox1_Change()
        'If we can undo, then make command1 enabled
        If SendMessage(RichTextBox1.hwnd, EM_CANUNDO, 0, 0&) <> 0 Then
            Command1.Enabled = True
        Else
            Command1.Enabled = False
        End If
        
        'If we can redo, then make command2 enabled
        If SendMessage(RichTextBox1.hwnd, EM_CANREDO, 0, 0&) <> 0 Then
            Command2.Enabled = True
        Else
            Command2.Enabled = False
        End If
        
    End Sub
    What codes do you have for the "Save As" and the "Print" sections so far?

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