Hi all,
I figured my own problem out.
I did this:
Public Class MyTextBox
Inherits TextBox
Private Const WM_COPY = &H301
Private Const WM_PASTE = &H302
Private Const WM_CUT = &H300
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'Stop the control from excepting paste commands
If m.Msg = WM_PASTE Then
Dim txt As String =
Clipboard.GetDataObject().GetData(GetType(String))
Return
End If
MyBase.WndProc(m)
End Sub
End Class
This works fine, do you have to always do it this way to add functionality
to the control? Can't you just entercept the
message from the form where the control is located?
One more thing how can I change the selected text color in a textbox?
Thanks
Gerry
> Hi all,
>
[quoted text clipped - 19 lines]
> Thanks for any help
> Gerry
"Ying-Shen Yu[MSFT]" - 13 Nov 2003 14:34 GMT
Hi Gerry,
I'm afraid you need do in this way, .NET TextBox class is a wrapper of the
unmanaged TextBox common control. In this case, you are trying to change
the default behavior of the unmanaged TextBox, you need override the
WndProc and do it in traditional way.
In your another question, as far as I know, the text box only support
setting the text color and back color,
it doesn't support setting the color of selected text. To set the selected
text color you may try the RichTextBox.
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending.
Gerry Viator - 13 Nov 2003 14:48 GMT
Thanks
Gerry
> Hi Gerry,
>
[quoted text clipped - 17 lines]
> You should not reply this mail directly, "Online" should be removed before
> sending.