Disable CUT-COPY-PASTE in VISIO 2003

A

Ayan

Hi

I am using Visio 2003 drawing control on my C# Windows form. There I
need to disable the cut/copy/paste/Undo/Redo operation on Visio shapes.
But i am not getting any way to do this. I tried to handle the Keydown
event also but that also is not working. Please someone tell me how to
disable the cut/copy/paste/Undo/Redo operations on visio drawing
control in C# or VB windows form.

Thanks in Advance,
Manish Gupta
(e-mail address removed)
 
J

JuneTheSecond

It might not be easy, because there are many ways to cut, copy and paste.
How would you like touse Visio viewer that could just show Visio drawing?
 
C

Chris Roth [MVP]

Hey Manish,

You might be able to do it via Visio's UI object. Have a look in the
developer help or the "Visio 2003 SDK" help for more information.

There you can:

- remove the Edit Cut/Copy menus
- remove keyboard shortcuts (I think)

Copy and Paste are so standard in Windows, I'm not 100% sure if you can get
rid of all the options, but it might be worth a shot.

You can turn of Visio's Undo buffer - something like : visApp.UndoEnabled =
False.

You can trap any pasting of a objec by looking at the ShapeAdded or
SelectionAdded events as well. But I'm not sure how easy it is to
distinguish between Paste as opposed to a "legitimate" drag-and-drop of a
master.

Hope these suggestions at least get you started!

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
Joined
Jun 7, 2012
Messages
1
Reaction score
0
(non-ideal) Solution

I was unable to find an adequate solution, so I am sharing how I was able to handle this problem. I use this code in the ShapeAdded event:

Code:
Private Sub dc1_ShapeAdded(ByVal shape As Visio.IVShape)
    ' check if we are in scope of a paste event
    If visApp.IsInScope(visCmdUFEditPaste) Or visApp.IsInScope(visCmdEditPasteSpecial) Then
        DeleteShape shape
    End If
End Sub

Private Sub DeleteShape(s As Visio.shape)
On Error Resume Next
    s.CellsSRC(visSectionObject, visRowLock, visLockDelete).formula = 0
    s.delete
    ' clear undo queue so user can't undelete shape
    dc1.Document.PurgeUndo
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top