Re: subclassing edit control and preventing copy paste clipboard

"amante1il" <[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
Hi Guys,

Thanks, this is what i have done: (see below)
BUT I do think there should be some other better way to do that ...
Deriving directly from CEdit, or adding CEdit the SubclassWindow procedure.
Or even some functions with in CEdit to do it ...

Anyway here is my solution:
// class that drives from CEdit in order to subclass an Edit Control and prevent copy paste
class CMyEdit : public CWindowImpl<CMyEdit, CEdit>
{
public:
	BEGIN_MSG_MAP(CMyEdit)
		  // your handlers...
		  MESSAGE_HANDLER(WM_RBUTTONDOWN, DoNothing)
		  MESSAGE_HANDLER(WM_COPY, DoNothing)
		  MESSAGE_HANDLER(WM_CUT, DoNothing)
		  MESSAGE_HANDLER(WM_PASTE, DoNothing)
		  MESSAGE_HANDLER(WM_CLEAR, DoNothing)
		  MESSAGE_HANDLER(WM_UNDO, DoNothing)
	END_MSG_MAP()
	// other stuff...

	LRESULT DoNothing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return TRUE;
	}
};


Best regards,
Don

--- In [email protected], "domehead100" <domehead100@...> wrote:
>
> --- In [email protected], "amante1il" <is.aviv@> wrote:
> >
> > Hi Guys,
> > 
> > I have an Edit Control in my dialog. I want to prevent the user from copying text with Ctrl+C and Clipboard functions with right click.
> > 
> > I tried Subclassing the Edit control with a CEdit class - but it dosen't have a SubClass function.
> > 
> > I tried catching the WM_COPY, WM_CUT etc' messages in the dialog, but it dosen't catch the Edit Control messages. Only on the dialog.
> > 
> > Any ideas how to do it?
> > 
> > Thanks in Advanced,
> > Don
> >
> 
> Use something like:
> 
> class CMyEdit : public CWindowImpl<CMyEdit, CEdit>
> {
> ...
> DECLARE_MSG_MAP(CMyEdit)
>    MSG_WM_COPY(OnCopy)
>    MSG_WM_PASTE(OnPaste)
> END_MSG_MAP()
> ...
> 
> }
> 
> This is how you subclass a window in WTL.  CWindowImpl-derived classes do have a SubclassWindow function.
> 
> I would recommend going to www.codeproject.com and locating and reading the articles in the WTL for MFC Programmers series.  They are a very good introduction to WTL, subclassing controls, etc.
> 
> ~Mike
>




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.