FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TRichEdit: disable copy
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TRichEdit: disable copy
Posted: Thu Nov 05, 2009 01: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

Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM
Re: TRichEdit: disable copy
Posted: Thu Nov 05, 2009 03: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.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TRichEdit: disable copy
Posted: Thu Nov 05, 2009 03:43 PM

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

EMG

Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM
Re: TRichEdit: disable copy
Posted: Fri Nov 06, 2009 08: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.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 128
Joined: Wed Oct 26, 2005 12:18 PM
Re: TRichEdit: disable copy
Posted: Sat Nov 07, 2009 03: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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TRichEdit: disable copy
Posted: Sat Nov 07, 2009 10:10 AM

Thank you. I already solved it using bKeyDown codeblock.

EMG

Posts: 128
Joined: Wed Oct 26, 2005 12:18 PM
Re: TRichEdit: disable copy
Posted: Sat Nov 07, 2009 03:16 PM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TRichEdit: disable copy
Posted: Sat Nov 07, 2009 03:20 PM

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

EMG

Continue the discussion