TRichEdit: disable copy
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
TRichEdit: disable copy
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
Thank you.
EMG
-
- Posts: 161
- Joined: Tue Oct 18, 2005 10:01 am
Re: TRichEdit: disable copy
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.
I changed my class to check lReadOnly state, and I enable and disable some operations like copy if it is true.
Regards,
Toninho.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: TRichEdit: disable copy
Yes, but I don't know how to prevent the user from select and copy the text.
EMG
EMG
-
- Posts: 161
- Joined: Tue Oct 18, 2005 10:01 am
Re: TRichEdit: disable copy
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.
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.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- César E. Lozada
- Posts: 128
- Joined: Wed Oct 26, 2005 12:18 pm
- Location: Los Teques, Miranda, Venezuela
Re: TRichEdit: disable copy
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
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
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: TRichEdit: disable copy
Thank you. I already solved it using bKeyDown codeblock.
EMG
EMG
- César E. Lozada
- Posts: 128
- Joined: Wed Oct 26, 2005 12:18 pm
- Location: Los Teques, Miranda, Venezuela
Re: TRichEdit: disable copy
but you can still copy using context right-click menu...
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: TRichEdit: disable copy
No, I already disable it too using bRClicked codeblock.
EMG
EMG