Hi,

does anyone know if there is a way to prevent pasting text in a EditBox
Control. The KeyPress-Event doesn't fire using ctrl-v and the following code
doesn't work:

Controls-Init-Event:
#define WM_PASTE 0x0302
BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")


Andy

Re: Prevent pasting by Bernhard

Bernhard
Sun Jun 11 07:08:20 CDT 2006

Hi Andreas

> does anyone know if there is a way to prevent pasting text in a EditBox
> Control. The KeyPress-Event doesn't fire using ctrl-v and the following code
> doesn't work:
This should do the trick: delete the Paste bar from all of your menus, also from
those that are not active.

Regards
Bernhard Sander

Re: Prevent pasting by Andreas

Andreas
Sun Jun 11 08:00:41 CDT 2006

Oh that's toooo mutch work for this little feature and i think there must be
an easier way to do this.

The following code works fine, but i've to edit an existing class which is
used in many forms and i don't want to check and rewrite these events in
dozent of my existing forms.

When- or GetFocus():
ON KEY LABEL CTRL+V DO something like return or execscript()

Valid or LostFocus():
ON KEY LABEL CTRL+V


"Bernhard Sander" <fuchs@individsoft.de> schrieb im Newsbeitrag
news:OujR9%23UjGHA.3440@TK2MSFTNGP02.phx.gbl...
> Hi Andreas
>
>> does anyone know if there is a way to prevent pasting text in a EditBox
>> Control. The KeyPress-Event doesn't fire using ctrl-v and the following
>> code doesn't work:
> This should do the trick: delete the Paste bar from all of your menus,
> also from those that are not active.
>
> Regards
> Bernhard Sander



Re: Prevent pasting by Bernhard

Bernhard
Sun Jun 11 11:55:30 CDT 2006

Hi Andreas,

> When- or GetFocus():
> ON KEY LABEL CTRL+V DO something like return or execscript()
The easiest way to do no meaningful thing is:
ON KEY LABEL CTRL+V *
This is: on key ctrl+v execute the command "comment". Maybe funny, but it works.

Regards
Bernhard Sander

Re: Prevent pasting by Andreas

Andreas
Sun Jun 11 13:08:26 CDT 2006

Bernhard,

i know that the "on key label" solution work (it was my own idea if you
remember), but i don't want to use this solution as i said in my previous
answer. So this solution is useless for me and i think that there must be a
better solution using the windows api and bindevents.


-Andy


"Bernhard Sander" <fuchs@individsoft.de> schrieb im Newsbeitrag
news:OQ9vafXjGHA.4512@TK2MSFTNGP04.phx.gbl...
> Hi Andreas,
>
>> When- or GetFocus():
>> ON KEY LABEL CTRL+V DO something like return or execscript()
> The easiest way to do no meaningful thing is:
> ON KEY LABEL CTRL+V *
> This is: on key ctrl+v execute the command "comment". Maybe funny, but it
> works.
>
> Regards
> Bernhard Sander



Re: Prevent pasting by Roger

Roger
Sun Jun 11 14:57:39 CDT 2006

Andreas Müller wrote:
> Bernhard,
>
> i know that the "on key label" solution work (it was my own idea if
> you remember), but i don't want to use this solution as i said in my
> previous answer. So this solution is useless for me and i think that
> there must be a better solution using the windows api and bindevents.

Seems to me that you haven't adequately explained your problem.

Bernhard provided a solution which works.
I can't think why it won't work for you as all you have to do is
modify your Editbox class's When & Valid events (or perhaps
GotFocus & LostFocus events) ...

<When Event>
On Key Label Ctrl+V *
(Or ... On Key Label Ctrl+V Return)

<Valid Event>
On Key Label Ctrl+V

Works fine for me.

Since it works, why the obsession with BindEvents?

Roger

>
> "Bernhard Sander" <fuchs@individsoft.de> schrieb im Newsbeitrag
> news:OQ9vafXjGHA.4512@TK2MSFTNGP04.phx.gbl...
>> Hi Andreas,
>>
>>> When- or GetFocus():
>>> ON KEY LABEL CTRL+V DO something like return or execscript()
>> The easiest way to do no meaningful thing is:
>> ON KEY LABEL CTRL+V *
>> This is: on key ctrl+v execute the command "comment". Maybe funny,
>> but it works.
>>
>> Regards
>> Bernhard Sander



Re: Prevent pasting by Bernhard

Bernhard
Mon Jun 12 03:33:44 CDT 2006

Hi Andreas,

> Enclosed an example...
Very interesting bug...

I think, the best solution would be: remove these paste bars from your menu.
Since this is the point where foxpro binds the paste functionality to the key.

Another idea, not tested: in interactivechange or maybe programmaticchange do
something like that:
IF lastkey() = 22 && ctrl+v
KEYBOARD "{ctrl+z}" && i.e.: undo pasting
ENDIF

Regards
Bernhard Sander

Re: Prevent pasting by Andrew

Andrew
Mon Jun 12 04:22:26 CDT 2006

In the Gotfocus event of the EditBox could you not just set _cliptext = ''

Paste would still work, but there would be nothing to paste.

Andrew R.

"Andreas Müller" <m.mueller@t-online.de> wrote in message
news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
: Hi,
:
: does anyone know if there is a way to prevent pasting text in a EditBox
: Control. The KeyPress-Event doesn't fire using ctrl-v and the following
code
: doesn't work:
:
: Controls-Init-Event:
: #define WM_PASTE 0x0302
: BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
:
:
: Andy
:
:



Re: Prevent pasting by Olaf

Olaf
Mon Jun 12 04:34:57 CDT 2006

Hi Andreas,

why not make the editbox readonly.
Usesrs than still can STRG+C (copy)
content and use the scrollbar, but not
paste anything. Also SET NOTIFY OFF
and you won't get the "control readonly"
message.

Bye, Olaf.



Re: Prevent pasting by Olaf

Olaf
Mon Jun 12 04:39:41 CDT 2006

> why not make the editbox readonly.

...?

> Usesrs than still can STRG+C (copy)

Users then ...

Bye, Olaf.



Re: Prevent pasting by Andrew

Andrew
Mon Jun 12 05:32:23 CDT 2006

"Andrew R" <adr @ rossers. net> wrote in message
news:4f4q2pF1gvfpuU1@individual.net...
> In the Gotfocus event of the EditBox could you not just set _cliptext = ''
>
> Paste would still work, but there would be nothing to paste.

I'm glad I'm not using this product, that is an evil workaround.. <g>

--
regards
Andrew Howell



Re: Prevent pasting by Andreas

Andreas
Mon Jun 12 13:49:55 CDT 2006

Olaf,

it's very simple -> users should be able to put some text in these control
"without using ctrl+v".


-Andy





"Olaf.Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU@strconv.14.de> schrieb im
Newsbeitrag news:%23rNPXRgjGHA.1640@TK2MSFTNGP02.phx.gbl...
>> why not make the editbox readonly.
>
> ...?
>
>> Usesrs than still can STRG+C (copy)
>
> Users then ...
>
> Bye, Olaf.
>
>



Re: Prevent pasting by Andreas

Andreas
Mon Jun 12 14:00:39 CDT 2006

Surely i can but the clipboard-content will be destroyed and that's not the
way!
A solution might be to store the clipboard content (GotFocus) and restore it
to
the clipboard in the LostFocus evtent.


-Andy


"Andrew R" <adr @ rossers. net> schrieb im Newsbeitrag
news:4f4q2pF1gvfpuU1@individual.net...
> In the Gotfocus event of the EditBox could you not just set _cliptext = ''
>
> Paste would still work, but there would be nothing to paste.
>
> Andrew R.
>
> "Andreas Müller" <m.mueller@t-online.de> wrote in message
> news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
> : Hi,
> :
> : does anyone know if there is a way to prevent pasting text in a EditBox
> : Control. The KeyPress-Event doesn't fire using ctrl-v and the following
> code
> : doesn't work:
> :
> : Controls-Init-Event:
> : #define WM_PASTE 0x0302
> : BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
> :
> :
> : Andy
> :
> :
>
>



Re: Prevent pasting by Imaginecorp

Imaginecorp
Mon Jun 12 20:48:39 CDT 2006

If I understand this correctly, you want users to be able to type text but
not paste using CTRL+V... Earlier you did not want to use ON KEY Label...
But now you do, am I correct so far? You also want to keep the text copied
in the clipboard. You attacthed a zip file which windows XP wont allow to be
extracted....Pretty confusing...

If I have it all wrong disregard this..

Got focus event
t = this.value
on key label ctrl+v wait " cannot paste " window nowait
this.value = t
Lost focus
on key label ctrl+v

Mohammed

"Andreas Müller" <m.mueller@t-online.de> wrote in message
news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> does anyone know if there is a way to prevent pasting text in a EditBox
> Control. The KeyPress-Event doesn't fire using ctrl-v and the following
> code doesn't work:
>
> Controls-Init-Event:
> #define WM_PASTE 0x0302
> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>
>
> Andy
>



Re: Prevent pasting by Andreas

Andreas
Tue Jun 13 04:02:40 CDT 2006

Mohammed,

yes you're right. I don't want to use the On Key Label CTRL+V but there's no
other way to disallow paste and allow typing. Currently i use following
code:

When-Event:
On Key Label CTRL+V return messagebox("bla", 64, "Error")-1
It's also possible to return .T. or .F. instead 0.

Valid-Event:
On Key Label CTRL+V

This seems to work but i am surprised that there's no other way like
Bindevents(_VFP.hWnd, 0x0302, ..., ...)


-Andy


"Imaginecorp" <imaginecorp@msn.com> schrieb im Newsbeitrag
news:e4v%239tojGHA.4304@TK2MSFTNGP03.phx.gbl...
> If I understand this correctly, you want users to be able to type text but
> not paste using CTRL+V... Earlier you did not want to use ON KEY Label...
> But now you do, am I correct so far? You also want to keep the text copied
> in the clipboard. You attacthed a zip file which windows XP wont allow to
> be extracted....Pretty confusing...
>
> If I have it all wrong disregard this..
>
> Got focus event
> t = this.value
> on key label ctrl+v wait " cannot paste " window nowait
> this.value = t
> Lost focus
> on key label ctrl+v
>
> Mohammed
>
> "Andreas Müller" <m.mueller@t-online.de> wrote in message
> news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> does anyone know if there is a way to prevent pasting text in a EditBox
>> Control. The KeyPress-Event doesn't fire using ctrl-v and the following
>> code doesn't work:
>>
>> Controls-Init-Event:
>> #define WM_PASTE 0x0302
>> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>>
>>
>> Andy
>>
>
>



Re: Prevent pasting by Olaf

Olaf
Tue Jun 13 07:06:34 CDT 2006

Hi Andreas,

> it's very simple -> users should be able to put some text in these control
> "without using ctrl+v".

Very simple? Very unusual.

But you can achieve it that way:

Editbox.Init():
This.Readonly = .T.
This.DisabledBackcolor = RGB(255,255,255)
* ...even better would be the theme related backcolor

Editbox.Keypress():
LPARAMETERS nKeyCode, nShiftAltCtrl
Thisform.LockScreen = .T. && optional
This.ReadOnly = .F.
DoDefault()
This.ReadOnly = .T.
NoDefault
Thisform.LockScreen = .F. && optional

The lockscreen related lines are optional, but prevent flickering
of the background color, especially if it is not set white.

Bye, Olaf.



Re: Prevent pasting by Andreas

Andreas
Tue Jun 13 11:43:18 CDT 2006

Very nice idea Olaf.

I think this can solve my problem. Not very beautifully because i have to
change the .DisabledBackgroundColor, but very helpfull. Because of my first
idea using Bindevents(), do you know how to handle this?


Thank you.

-Andy


"Olaf.Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU@strconv.14.de> schrieb im
Newsbeitrag news:Ou5BIIujGHA.4040@TK2MSFTNGP05.phx.gbl...
> Hi Andreas,
>
>> it's very simple -> users should be able to put some text in these
>> control "without using ctrl+v".
>
> Very simple? Very unusual.
>
> But you can achieve it that way:
>
> Editbox.Init():
> This.Readonly = .T.
> This.DisabledBackcolor = RGB(255,255,255)
> * ...even better would be the theme related backcolor
>
> Editbox.Keypress():
> LPARAMETERS nKeyCode, nShiftAltCtrl
> Thisform.LockScreen = .T. && optional
> This.ReadOnly = .F.
> DoDefault()
> This.ReadOnly = .T.
> NoDefault
> Thisform.LockScreen = .F. && optional
>
> The lockscreen related lines are optional, but prevent flickering
> of the background color, especially if it is not set white.
>
> Bye, Olaf.
>
>



Re: Prevent pasting by Andreas

Andreas
Tue Jun 13 12:22:16 CDT 2006

Thank you to all.

My last workaround shows that ON KEY LABEL CTRL+V RETURN solve this problem.

BUT: Playing with my keyboard i noticed that SHIFT-INS also paste text from
the clipboard to my control but there's no way to handle ON KEY LABEL
SHIFT+INS!


-Andy


"Andreas Müller" <m.mueller@t-online.de> schrieb im Newsbeitrag
news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> does anyone know if there is a way to prevent pasting text in a EditBox
> Control. The KeyPress-Event doesn't fire using ctrl-v and the following
> code doesn't work:
>
> Controls-Init-Event:
> #define WM_PASTE 0x0302
> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>
>
> Andy
>



Re: Prevent pasting by Dan

Dan
Tue Jun 13 15:33:43 CDT 2006

SHIFT+INS is lower-level than CTRL-V. You'll occasionally see Windows apps
that don't support CTRL-V because they didn't implement that part of the
Windows foundation, but SHIFT-INS will still be supported because it
predates the whole Windows interface. It comes from IBM's CUA spec, and is
deep in the Windows bone marrow.

Dan



Andreas Müller wrote:
> Thank you to all.
>
> My last workaround shows that ON KEY LABEL CTRL+V RETURN solve this
> problem.
>
> BUT: Playing with my keyboard i noticed that SHIFT-INS also paste
> text from the clipboard to my control but there's no way to handle ON
> KEY LABEL SHIFT+INS!
>
>
> -Andy
>
>
> "Andreas Müller" <m.mueller@t-online.de> schrieb im Newsbeitrag
> news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> does anyone know if there is a way to prevent pasting text in a
>> EditBox Control. The KeyPress-Event doesn't fire using ctrl-v and
>> the following code doesn't work:
>>
>> Controls-Init-Event:
>> #define WM_PASTE 0x0302
>> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>>
>>
>> Andy



Re: Prevent pasting by Andreas

Andreas
Tue Jun 13 16:18:23 CDT 2006

Dan,

thanks for this very usefull information. Do you know an other way to
disallow my users to "paste" text in EditBox Controls but allow them to type
text?


-Andy


"Dan Freeman" <spam@microsoft.com> schrieb im Newsbeitrag
news:%234hqqiyjGHA.4040@TK2MSFTNGP05.phx.gbl...
> SHIFT+INS is lower-level than CTRL-V. You'll occasionally see Windows apps
> that don't support CTRL-V because they didn't implement that part of the
> Windows foundation, but SHIFT-INS will still be supported because it
> predates the whole Windows interface. It comes from IBM's CUA spec, and is
> deep in the Windows bone marrow.
>
> Dan
>
>
>
> Andreas Müller wrote:
>> Thank you to all.
>>
>> My last workaround shows that ON KEY LABEL CTRL+V RETURN solve this
>> problem.
>>
>> BUT: Playing with my keyboard i noticed that SHIFT-INS also paste
>> text from the clipboard to my control but there's no way to handle ON
>> KEY LABEL SHIFT+INS!
>>
>>
>> -Andy
>>
>>
>> "Andreas Müller" <m.mueller@t-online.de> schrieb im Newsbeitrag
>> news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> does anyone know if there is a way to prevent pasting text in a
>>> EditBox Control. The KeyPress-Event doesn't fire using ctrl-v and
>>> the following code doesn't work:
>>>
>>> Controls-Init-Event:
>>> #define WM_PASTE 0x0302
>>> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>>>
>>>
>>> Andy
>
>



Re: Prevent pasting by Olaf

Olaf
Tue Jun 13 16:39:42 CDT 2006

> I think this can solve my problem. Not very beautifully because i have to
> change the .DisabledBackgroundColor, but very helpfull. Because of my
> first idea using Bindevents(), do you know how to handle this?

Not as far as I know. You may find this additional informations
helpful:

Here you find the WM_PASTE constant:
MODIFY FILE (_samples+"Solution\Europa\wmhandler.h")

And in the (_samples+"Solution\solution.app") you also have
some source code in how to use BindEvent with Windows
Messages.

Bye, Olaf.



Re: Prevent pasting by Dan

Dan
Tue Jun 13 17:53:18 CDT 2006

No, and I can't think of a single reason this might be desireable. <s>

If a control accepts input, it should accept input from the keyboard, paste,
voice recognition, handwriting recognition, IME editors, etc. -- if it
shouldn't accept input, it shouldn't accept ANY input. <shrug>

Dan

Andreas Müller wrote:
> Dan,
>
> thanks for this very usefull information. Do you know an other way to
> disallow my users to "paste" text in EditBox Controls but allow them
> to type text?
>
>
> -Andy
>
>
> "Dan Freeman" <spam@microsoft.com> schrieb im Newsbeitrag
> news:%234hqqiyjGHA.4040@TK2MSFTNGP05.phx.gbl...
>> SHIFT+INS is lower-level than CTRL-V. You'll occasionally see
>> Windows apps that don't support CTRL-V because they didn't implement
>> that part of the Windows foundation, but SHIFT-INS will still be
>> supported because it predates the whole Windows interface. It comes
>> from IBM's CUA spec, and is deep in the Windows bone marrow.
>>
>> Dan
>>
>>
>>
>> Andreas Müller wrote:
>>> Thank you to all.
>>>
>>> My last workaround shows that ON KEY LABEL CTRL+V RETURN solve this
>>> problem.
>>>
>>> BUT: Playing with my keyboard i noticed that SHIFT-INS also paste
>>> text from the clipboard to my control but there's no way to handle
>>> ON KEY LABEL SHIFT+INS!
>>>
>>>
>>> -Andy
>>>
>>>
>>> "Andreas Müller" <m.mueller@t-online.de> schrieb im Newsbeitrag
>>> news:%23ls15rUjGHA.1324@TK2MSFTNGP04.phx.gbl...
>>>> Hi,
>>>>
>>>> does anyone know if there is a way to prevent pasting text in a
>>>> EditBox Control. The KeyPress-Event doesn't fire using ctrl-v and
>>>> the following code doesn't work:
>>>>
>>>> Controls-Init-Event:
>>>> #define WM_PASTE 0x0302
>>>> BINDEVENT(_VFP.hWnd, WM_PASTE, This, "KeyPress")
>>>>
>>>>
>>>> Andy



Re: Prevent pasting by Olaf

Olaf
Wed Jun 14 08:41:13 CDT 2006

Hi Andreas,

> thanks for this very usefull information. Do you know an other way to
> disallow my users to "paste" text in EditBox Controls but allow them to
> type text?

Whats your reason for this demand?
Because they should limit, what they type in?
Then why not simply make use of .MaxLength?

Bye, Olaf.