Page 1 of 1

TRichEdit: disable copy

Posted: Thu Nov 05, 2009 1:48 pm
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

Re: TRichEdit: disable copy

Posted: Thu Nov 05, 2009 3:34 pm
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.

Re: TRichEdit: disable copy

Posted: Thu Nov 05, 2009 3:43 pm
by Enrico Maria Giordano
Yes, but I don't know how to prevent the user from select and copy the text.

EMG

Re: TRichEdit: disable copy

Posted: Fri Nov 06, 2009 8:57 pm
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.

Re: TRichEdit: disable copy

Posted: Fri Nov 06, 2009 9:44 pm
by Enrico Maria Giordano
:(

EMG

Re: TRichEdit: disable copy

Posted: Sat Nov 07, 2009 3:07 am
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

Re: TRichEdit: disable copy

Posted: Sat Nov 07, 2009 10:10 am
by Enrico Maria Giordano
Thank you. I already solved it using bKeyDown codeblock.

EMG

Re: TRichEdit: disable copy

Posted: Sat Nov 07, 2009 3:16 pm
by César E. Lozada
but you can still copy using context right-click menu...

Re: TRichEdit: disable copy

Posted: Sat Nov 07, 2009 3:20 pm
by Enrico Maria Giordano
No, I already disable it too using bRClicked codeblock. :-)

EMG