Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

Clearing the Clipboard to Prevent a Copy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cindy - 26 Jul 2004 20:02 GMT
I need to prevent a user from copying\pasting text that is displayed
in an RichTestbox control. Since the control doesn't seem to have a
property for this -- the user can mouse over and hit ctrl-c to copy
and then ctrl-v to paste -- I use the KeyDown event to catch the copy
and then try to prevent the paste.

In the KeyDown method, I check for ctrl-c and then call
Clipboard.SetDataObject(0, true). The odd behavior is that when I
debug the application with a breakpoint in KeyDown(), the paste is
empty and the copy prevented. But when I run the app with a breakpoint
set, the text remains in the clipboard and the paste is successful.

Does anyone know how I can get this to work correctly? Or is there a
better way to prevent copy\paste of text from a rtf control? BTW, I
tried using OpenClipboard(), EmptyClipboard(), and CloseClipboard()
APIs with PInvoke, but the EmptyClipboard kept failing.

Thanks,
Cindy
Claes Bergefall - 27 Jul 2004 08:54 GMT
Have you tried overriding the ProcessCmdKey method?
That works for textboxes, so I guess it should work for
richtextbox aswell. Just return true for Ctrl+C, Ctrl+V
and Shift+Insert (another way to paste)

   /claes

> I need to prevent a user from copying\pasting text that is displayed
> in an RichTestbox control. Since the control doesn't seem to have a
[quoted text clipped - 15 lines]
> Thanks,
> Cindy
cindy fisher - 27 Jul 2004 16:21 GMT
Thanks, that worked perfectly.

Cindy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.