Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars 
Author Message
 Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

The application that I am working uses a Multiple Document Interface
(MDI).  I need cut/copy/paste menu's and toolbars to be enabled/disabled
as appropriate.

For menu's, this is simple.  I use an event that is triggered befor the
menu is "popped open," and enable/disable the menu items as necessary.

However, to make buttons on a toolbar context sensitive as far as
cut/copy/paste, I'm not sure what would be the best way to do it.. .
Maybe hook one of the controls messages?  That could get ugly and be
very dangerous...

Any ideas, suggestions?

Thanks in advance.

-Yarone Goren



Sat, 12 Aug 2000 03:00:00 GMT  
 Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

You can put code in every control's GotFocus and LostFocus events and the
form's Activate and Deactivate Events. This is long winded and prone to
errors.

OR

You put a timer control on the MDI form set for an interval of 500 or so
(half a second). In the Timer event you check ActiveForm.ActiveControl to
find out where the focus is. You can also check the Clipboard object to see
if there is any data (of the right format) that can be pasted into the
ActiveControl. This should give you enough information to enable/disable
your toolbar buttons.

You can use the same trick with RichText boxes and the Bold, Italic and
Underline buttons.

Regards,
Simon Jones
PC Pro Magazine



Sat, 12 Aug 2000 03:00:00 GMT  
 Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

This is the code that I use:

In a module I have this:

Public Sub EditEnable()
    Screen.MousePointer = vbHourglass
    Dim shirley As Boolean
    shirley = False
    frmMain.mnuPaste.Enabled = False
    If TypeOf frmMain.ActiveForm.ActiveControl Is TextBox Then
        If Clipboard.GetFormat(vbCFText) Then frmMain.mnuPaste.Enabled =
True
        If frmMain.ActiveForm.ActiveControl.SelLength > 0 Then shirley =
True
    End If
    frmMain.mnuCut.Enabled = shirley
    frmMain.mnuCopy.Enabled = shirley
    Screen.MousePointer = vbDefault
End Sub

then I call Edit Enable from the child forms with these:

Private Sub text1_GotFocus()
    EditEnable
End Sub
Private Sub text1_KeyUp(KeyCode As Integer, Shift As Integer)
    EditEnable
End Sub

Quote:

> The application that I am working uses a Multiple Document Interface
> (MDI).  I need cut/copy/paste menu's and toolbars to be enabled/disabled
> as appropriate.

> For menu's, this is simple.  I use an event that is triggered befor the
> menu is "popped open," and enable/disable the menu items as necessary.

> However, to make buttons on a toolbar context sensitive as far as
> cut/copy/paste, I'm not sure what would be the best way to do it.. .
> Maybe hook one of the controls messages?  That could get ugly and be
> very dangerous...

> Any ideas, suggestions?

> Thanks in advance.

> -Yarone Goren

--
Dave & Sara Emmert

homepage: www.geocities.com/~demmert


Sun, 13 Aug 2000 03:00:00 GMT  
 Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

If you want to see how to manage cut/copy/paste in "real-time" check out a
FREE sample I've written on my web site. It's on the "examples" page of my
"downloads" section. Look for "clipboard.exe".

The examples shows how to sub-class VB5 to manage and control clipboard
events.

http://henge1.henge.com/~rabit/main_index.htm

Tom Hare
MCP/MVP



Mon, 14 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

2. Enable/Disable of CUT, COPY, PASTE Menu's/Toolbars

3. Enabling/Disabling Cut, Copy, Paste

4. disabling copy/paste/cut on shape shortcut menu

5. Disable TxtBox Copy/Cut/Paste Menu?

6. disabling cut/copy/paste

7. Disabling Copy Cut Paste

8. Toolbar (cut copy paste ) problem VB4

9. Cut, Copy and Paste in the menu bar

10. Creating my own right-mouse-button cut-copy/paste menu

11. Cut/Copy/Paste ShortCut menu for ListView control?

12. Can't Implement Cut, Copy, Paste

 

 
Powered by phpBB® Forum Software