|
-
Oct 17th, 2003, 11:09 AM
#1
Thread Starter
I wonder how many charact
hehe.. stop beep when pressing Enter
You know how the system beeps if you try to press
Enter in a single-line textbox...
Well, anyway, I making a usercontrol that I want to just pass a TAB along to the system... I found this code in C#, I know Pirate has # skills, so perhaps he can convert this to VB...
Code:
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
public override bool PreProcessMessage(ref
System.Windows.Forms.Message msg)
{
Keys keyCode=(Keys)(int)msg.WParam & Keys.KeyCode;
if((msg.Msg==WM_KEYDOWN || msg.Msg==WM_KEYUP) &&
keyCode==Keys.Enter)
{
msg.WParam=(System.IntPtr)Keys.Tab;
}
return base.PreProcessMessage(ref msg);
}
Here's what I have so far....
VB Code:
Dim keyCode As Keys = CType(msg.WParam, IntPtr).ToInt32
If msg.Msg = Convert.ToInt32("0x100") Then
If keyCode = Keys.Enter Then
msg.WParam = New IntPtr(Keys.Tab)
Return True
End If
End If
Return MyBase.ProcessKeyEventArgs(msg)
I think that's correct except msg.Msg = "0x100"
probably stops this routine from working correctly.
So, how do I say:
If msg.Msg = WM_KEYUP or msg.Msg = WM_KEYDOWN
Last edited by nemaroller; Oct 17th, 2003 at 11:37 AM.
-
Oct 17th, 2003, 11:50 AM
#2
Thread Starter
I wonder how many charact
Ok... I got this part to work... no beep, but I still want it to send a Tab...
VB Code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Dim keyCode As Keys = CType(msg.WParam, IntPtr).ToInt32
Const WM_KEYDOWN As Integer = &H100
Const WM_KEYUP As Integer = &H101
If msg.Msg = WM_KEYDOWN AndAlso keyCode = Keys.Enter Then
msg.WParam = New IntPtr(Keys.Tab)
Return True
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
-
Oct 17th, 2003, 11:55 AM
#3
-
Oct 17th, 2003, 12:10 PM
#4
Thread Starter
I wonder how many charact
I tried e.handled, but could not get it work properly...
Anyway, the above code works, but now I have to figure out why its not replacing the .Wparam with the tab instead of Enter.
-
Oct 17th, 2003, 12:17 PM
#5
Thread Starter
I wonder how many charact
YES!
GOT IT! (by cheating using me.parentform.selectnextcontrol, but ***)
VB Code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Dim keyCode As Keys = CType(msg.WParam, IntPtr).ToInt32
Const WM_KEYDOWN As Integer = &H100
'Const WM_KEYUP As Integer = &H101 in case people need this
If msg.Msg = WM_KEYDOWN AndAlso keyCode = Keys.Enter Then
Me.ParentForm.SelectNextControl(Me, True, True, False, True)
Return True
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
-
Oct 17th, 2003, 12:18 PM
#6
umm I'm not answering your directly but, you coudl do something like tihs:
Me.SelectNextControl(TextBox1, True, True, True, True)
that would select the control after textbox1.... that is, if you are trying to pass teh focus to some other control
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 17th, 2003, 12:18 PM
#7
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|