Home › Forums › WinForms controls › Other WinForms controls › WndProc override on WinNumericTextBox
-
AuthorPosts
-
#18537 |
Hi there,
Using the WinNumericTextBox, I’ve been trying to use a technique I have used successfully on a standard TextBox.
Basically I want to suppress double clicks and right clicks (i.e. copy/paste context menu) since I just want to respond to the MouseClick event. I want the value in the textbox to increase when you right click and decrease when you left click.
I had this working using a standard textbox where I defined this:
#region Constants
private const int WM_RBUTTONUP = 0x0205; // Windows message for Right Mouse button up event
private const int WM_RBUTTONDOWN = 0x0204; // Windows message for Right Mouse button down event
private const int WM_LBUTTONDBLCLK = 0x0203; // // Windows message for Left Mouse button double-click event
#endregion
#region Methods/// <summary>/// Override control message processing procedure to disable the right-click context menu popup behaviour/// </summary>/// <param name=”m”></param>protected override void WndProc(ref Message m){switch (m.Msg){// Thuiscase WM_LBUTTONDBLCLK:// Return to disable “select all” behavour of textbox.return;case WM_RBUTTONDOWN:// Return to disable right button down eventreturn;case WM_RBUTTONUP:// get x and y positions of the mouseint x = m.LParam.ToInt32() & 0xFFFF;int y = (m.LParam.ToInt32() >> 16) & 0xFFFF;OnMouseClick(new MouseEventArgs(MouseButtons.Right, 1, x, y, 0));// Return to disable default event handler for right buttonreturn;}base.WndProc(ref m);}#endregionSome events do get into the WndProc method but crucially, the click events do not – the switch statement never gets activated.Is this a bug or something by design?Regards,JamesImported from legacy forums. Posted by James (had 3190 views)
We have not tested this, but it is possible that the click messages are handled by the TextBoxArea, and not the WinNumericTextBox as such.
If so, it would imply you would have to derive from WinNumericTextBox and override CreateTextBoxArea, to return an new instance of your own customNumericTextBoxArea, itself deriving from NumericTextBoxArea in which you override WndProc.
Imported from legacy forums. Posted by André (had 1888 views)
Thanks! – we are looking into that.Imported from legacy forums. Posted by James (had 3005 views)
-
AuthorPosts
- You must be logged in to reply to this topic.