|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Prohibit PasteI 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 Bee wrote:
> I want an control, e.g. combobox, to accept typed characters, but not text You could probably hook/eat WM_PASTE, eh?> pasted into it. How do I tell if it is a paste operation and prohibit it > from changing the control? VB6 "Bee" <B**@discussions.microsoft.com> wrote in message You can supress Ctrl+V with the following code, but that doesn't block 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 "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 "Nobody" <nob***@nobody.com> wrote in message Nor does it block Shift+Insert.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. 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.) 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 I'm curious. Why if you are allowing input can't I paste>pasted into it. How do I tell if it is a paste operation and prohibit it >from changing the control? VB6 into it? -- Jan Hyde "Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message The usual applications I've seen do this are ones where they want you to news:03tp15tb4h2jlrhusnts7r10ubb3rrueue@4ax.com... > I'm curious. Why if you are allowing input can't I paste > into it? enter an email address, then enter it again for verification. Some apps have disabled paste on the verification part. 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 > 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... "Bee" <B**@discussions.microsoft.com> wrote in message I have to agree with Karl. Sometimes, passwords (especially those someone 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 >> 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 "MikeD" <nob***@nowhere.edu> wrote in message I think Bee might have meant verifying a new password, although why he was news:efUyKqy3JHA.4272@TK2MSFTNGP06.phx.gbl... > And really, what's the danger? Either way, you still KNOW the password. 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
Help with a bit of maths
Create Icon File From Resource Anyone know of a good Help Authorizing Tool Changing a property on a control Vista and AutoRedraw Phone system integrated in vb app Sort UDT vs Database How do I stop opportunistic record locking from causing massive de General Question on Deployment Stratagies XML in VB |
|||||||||||||||||||||||