Results 1 to 7 of 7

Thread: hehe.. stop beep when pressing Enter

Threaded View

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    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:
    1. Dim keyCode As Keys = CType(msg.WParam, IntPtr).ToInt32
    2.  
    3.  
    4.         If msg.Msg = Convert.ToInt32("0x100") Then
    5.             If keyCode = Keys.Enter Then
    6.                 msg.WParam = New IntPtr(Keys.Tab)
    7.                 Return True
    8.             End If
    9.         End If
    10.         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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width