TRichEdit: disable copy

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

TRichEdit: disable copy

Post by Enrico Maria Giordano »

Dear friends, is there a way to disable copy operation? I need to show a multipage document so I can't disable the control and READONLY clause still allows to select the text.

Thank you.

EMG
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Re: TRichEdit: disable copy

Post by toninhofwi »

Hi Enrico.

I changed my class to check lReadOnly state, and I enable and disable some operations like copy if it is true.

Regards,

Toninho.
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Re: TRichEdit: disable copy

Post by toninhofwi »

Enrico,

Maybe this article can help you, but you need change richedit.c that is not provide with fwh:

http://www.codeguru.com/cpp/controls/ri ... php/c2401/



Regards,

Toninho.
User avatar
César E. Lozada
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Re: TRichEdit: disable copy

Post by César E. Lozada »

I think this will avoid Copy, although you can still select a text:

1) Yo have to EXTEND CLASS tRichEdit WITH DATA lCanCopy
2) you have to edit and override Method CanCopy, Method Copy and Method KeyDown (to handle CTRL-C) in class tRichEdit.

METHOD CanCopy() INLINE ((ValType(::lCanCopy)<>"L" .or. ::lCanCopy) .and. ::IsSelection()) //This disables Copy option in rigth click menu

METHOD Copy() CLASS TRichEdit
#ifdef __XPP__
#undef New
#endif
DEFAULT ::lCanCopy:=.T.
if ::lCanCopy
::SendMsg( WM_COPY )
endif
return nil

METHOD KeyDown( nKey, nFlags ) CLASS TRichEdit

if (nKey == Asc( "C" ) .and. GetKeyState( VK_CONTROL ) )
::Copy()
return 0
endif
:
:

Regards
User avatar
César E. Lozada
Posts: 128
Joined: Wed Oct 26, 2005 12:18 pm
Location: Los Teques, Miranda, Venezuela

Re: TRichEdit: disable copy

Post by César E. Lozada »

but you can still copy using context right-click menu...
Post Reply