Home All Groups Group Topic Archive Search About
Author
27 May 2009 12:35 AM
Bee
I want an control, e.g. combobox, to accept typed characters, but not text
pasted into it.  How do I tell if it is a paste operation and prohibit it
from changing the control?  VB6

Author
27 May 2009 12:48 AM
Karl E. Peterson
Bee wrote:
> I want an control, e.g. combobox, to accept typed characters, but not text
> pasted into it.  How do I tell if it is a paste operation and prohibit it
> from changing the control?  VB6

You could probably hook/eat WM_PASTE, eh?
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
27 May 2009 2:03 AM
Nobody
"Bee" <B**@discussions.microsoft.com> wrote in message
news:E58DDA7A-102C-4325-A61E-35C661E9E069@microsoft.com...
>I want an control, e.g. combobox, to accept typed characters, but not text
> pasted into it.  How do I tell if it is a paste operation and prohibit it
> from changing the control?  VB6

You can supress Ctrl+V with the following code, but that doesn't block
"Paste" from the context menu. You need to subclass and intercept WM_PASTE
if you want to block it too.

Private Sub Combo1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 22 Then ' Ctrl+V
        KeyAscii = 0
    End If
End Sub
Author
27 May 2009 5:47 PM
Jeff Johnson
"Nobody" <nob***@nobody.com> wrote in message
news:OFNrf9m3JHA.2656@TK2MSFTNGP05.phx.gbl...

> You can supress Ctrl+V with the following code, but that doesn't block
> "Paste" from the context menu.

Nor does it block Shift+Insert.

Seriously, people, learn about the OTHER set of cut/copy/paste shortcuts.
(And implement them in your own apps, too! We left-handed mouse users will
thank you.)
Author
27 May 2009 8:06 AM
Jan Hyde
Bee <B**@discussions.microsoft.com>'s wild thoughts were
released on Tue, 26 May 2009 17:35:01 -0700 bearing the
following fruit:

>I want an control, e.g. combobox, to accept typed characters, but not text
>pasted into it.  How do I tell if it is a paste operation and prohibit it
>from changing the control?  VB6

I'm curious. Why if you are allowing input can't I paste
into it?
--
Jan Hyde
Author
27 May 2009 4:15 PM
Nobody
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:03tp15tb4h2jlrhusnts7r10ubb3rrueue@4ax.com...
> I'm curious. Why if you are allowing input can't I paste
> into it?

The usual applications I've seen do this are ones where they want you to
enter an email address, then enter it again for verification. Some apps have
disabled paste on the verification part.
Author
27 May 2009 5:08 PM
Bee
password verification.

Show quoteHide quote
"Bee" wrote:

> I want an control, e.g. combobox, to accept typed characters, but not text
> pasted into it.  How do I tell if it is a paste operation and prohibit it
> from changing the control?  VB6
>
Author
27 May 2009 7:13 PM
Karl E. Peterson
Bee wrote:
> password verification.

And it's probably obscured, too, right?  Argh!  Nothing would piss me off more.  In
those cases, if it's *really* important, I'll type the password where I can see it,
then cut/paste it into those boxes.

And what are you doing using a combobox for password verification anyway?  The mind
boggles...
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
28 May 2009 12:23 AM
MikeD
"Bee" <B**@discussions.microsoft.com> wrote in message
news:F5B4CEB5-4803-4C48-A0FF-8BCA18CF729A@microsoft.com...
> password verification.
>
> "Bee" wrote:
>
>> I want an control, e.g. combobox, to accept typed characters, but not
>> text
>> pasted into it.  How do I tell if it is a paste operation and prohibit it
>> from changing the control?  VB6
>>

I have to agree with Karl.  Sometimes, passwords (especially those someone
else assigns) are so, hmm, can't even think of the right word.  Anyway, if
you had to type the password, you may never get it right.  <g>  Just for an
example, sometimes it's hard to discern between an uppercase letter O and a
0 or a lowercase letter l (that's an L) and a 1.

Much easier to copy and paste it (assuming the password's not written down
and you'd need to type it anyway). And really, what's the danger? Either
way, you still KNOW the password.  Being forced to type it doesn't make
anything more secure. The security is the password itself, NOT how you enter
it. With that said, I DON'T think it's a good idea for a password to be
saved and entered *automatically* (like IE can do, and some web sites that
save it somewhere). Entering a password should be a manual process, yes, but
nothing wrong with manually pasting it.

That's the problem with too many programs nowadays. Their so
non-user-friendly, they're too annoying to be useful. As far as I'm
concerned, Vista is a perfect example.  To be fair, however, I don't think
Vista's entirely at fault.  Much is due to programmers who don't know how to
write programs properly (as in designed to be run by a standard user and not
an administrator).

At least, that's my opinion.

--
Mike
Author
28 May 2009 3:02 AM
Michael Williams
"MikeD" <nob***@nowhere.edu> wrote in message
news:efUyKqy3JHA.4272@TK2MSFTNGP06.phx.gbl...

> And really, what's the danger? Either way, you still KNOW the password.

I think Bee might have meant verifying a new password, although why he was
using a ComboBox isn't clear, unless of course he just mentioned that
control as an example. For example, the user might have entered his old
password in order that your program will allow him to change it to something
else. Errors in typing in the old password are of course not a problem,
because your program would simply refuse to allow the new password process
to complete and would inform the user that the old password he entered is
invalid, giving him the chance to try again. However, it would be wise to
ask the user to enter the new password twice, and to prevent him from
copying the first entry and pasting it into the second on the grounds that
if he did that and had made a mistake when entering it into the first box
then that mistake would also be made in the second box, because it contained
an exact copy of the first entry. Asking him to enter the new password twice
and not allowing him to paste the first entry into the second (forcing him
to retype it) makes sense in these circumstances and it minimizes the chance
of the user accidentally entering a password other than the one he has "in
his head". I would agree with Karl and say that the best way of preventing
the paste operation would be to hook the WM_PASTE message for the control
and "eat it". [To the OP: Presumably you know how to perform that task
because you have not posted any further questions in response to Karl's
suggestion, but if you are having problems with it them post again].

Mike