I made an ButtonEditor usercontrol with one TextBox and one Button. How to disable TextBox's paste operation from Right Click Menu "Paste" ? Right now, my method is to create a Class called "CustomMenuTextBox.cs" which Subclassed msg "WM_INITMENU" and "WM_INITMENUPOPUP" to call Win32 API EnableMenuItem. But I don't know how to implement two inherits.
The ButtonEditor.cs look like:
internal partial class ButtonEditor : UserControl
{
//add a textbox and a button from toolbox and some codes...
}
The CustomMenuTextBox.cs look like:
internal partial class CustomMenuTextBox : TextBox
{
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0093 /*WM_UAHINITMENU*/ || m.Msg == 0x0117 /*WM_INITMENUPOPUP*/ || m.Msg == 0x0116 /*WM_INITMENU*/)
{
IntPtr menuHandle = m.Msg == 0x0093 ? Marshal.ReadIntPtr(m.LParam) : m.WParam;
// MF_BYPOSITION and MF_GRAYED
mAPI.EnableMenuItem(menuHandle, 4, 0x00000400 | 0x00000001);
}
base.WndProc(ref m);
}
}
I got an error:
internal partial class ButtonEditor : CustomMenuTextBox, UserControl
I know I may make totally wrong way for disable Paste operation for TextBox right click menu. Please show me the right way.