TRichEdit: disable copy

TRichEdit: disable copy

Postby Enrico Maria Giordano » Thu Nov 05, 2009 1:48 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TRichEdit: disable copy

Postby toninhofwi » Thu Nov 05, 2009 3:34 pm

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: 170
Joined: Tue Oct 18, 2005 10:01 am

Re: TRichEdit: disable copy

Postby Enrico Maria Giordano » Thu Nov 05, 2009 3:43 pm

Yes, but I don't know how to prevent the user from select and copy the text.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TRichEdit: disable copy

Postby toninhofwi » Fri Nov 06, 2009 8:57 pm

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.
toninhofwi
 
Posts: 170
Joined: Tue Oct 18, 2005 10:01 am


Re: TRichEdit: disable copy

Postby César E. Lozada » Sat Nov 07, 2009 3:07 am

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

Postby Enrico Maria Giordano » Sat Nov 07, 2009 10:10 am

Thank you. I already solved it using bKeyDown codeblock.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TRichEdit: disable copy

Postby César E. Lozada » Sat Nov 07, 2009 3:16 pm

but you can still copy using context right-click menu...
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

Postby Enrico Maria Giordano » Sat Nov 07, 2009 3:20 pm

No, I already disable it too using bRClicked codeblock. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests

cron