none
怎么做这个! RRS feed

  • 问题

  • 我用个窗体做了个软键盘,怎么才能让Form2中的Text接收到Form1的软键盘指令?
    还有软键盘出现的位置怎么使他在Form2text的下面?

    2009年10月26日 9:13

全部回复

  • 我的代码
    Public Class keyboard
      
        Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
            Get
                Dim Cp As CreateParams = MyBase.CreateParams
                Cp.ExStyle = Cp.ExStyle Or CInt(134217728L)
    
                Return Cp
    
            End Get
        End Property
        Private Sub keyboard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    
    
        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            SendKeys.Send("1")
        End Sub
    
        Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
            SendKeys.Send("2")
        End Sub
    
        Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
            SendKeys.Send("3")
        End Sub
    
        Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
            SendKeys.Send("4")
        End Sub
    
        Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
            SendKeys.Send("5")
        End Sub
    
        Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
            SendKeys.Send("6")
        End Sub
    
        Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
            SendKeys.Send("7")
        End Sub
    
        Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
            SendKeys.Send("8")
    
        End Sub
    
        Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
            SendKeys.Send("9")
        End Sub
    
        Private Sub Button0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button0.Click
            SendKeys.Send("0")
        End Sub
    
        Private Sub Buttona_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttona.Click
            SendKeys.Send("a")
        End Sub
    
        Private Sub Buttonb_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonb.Click
            SendKeys.Send("b")
        End Sub
    
        Private Sub Buttonc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonc.Click
            SendKeys.Send("c")
        End Sub
    
        Private Sub Buttond_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttond.Click
            SendKeys.Send("d")
        End Sub
    
        Private Sub Buttone_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttone.Click
            SendKeys.Send("e")
        End Sub
    
        Private Sub Buttonf_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonf.Click
            SendKeys.Send("f")
        End Sub
    
        Private Sub Buttong_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttong.Click
            SendKeys.Send("g")
        End Sub
    
        Private Sub Buttonh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonh.Click
            SendKeys.Send("h")
        End Sub
    
        Private Sub Buttoni_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttoni.Click
            SendKeys.Send("i")
        End Sub
    
        Private Sub Buttonj_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonj.Click
            SendKeys.Send("j")
        End Sub
    
        Private Sub Buttonk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonk.Click
            SendKeys.Send("k")
        End Sub
    
        Private Sub Buttonl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonl.Click
            SendKeys.Send("l")
        End Sub
    
        Private Sub Buttonm_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonm.Click
            SendKeys.Send("m")
        End Sub
    
        Private Sub Buttonn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonn.Click
            SendKeys.Send("n")
        End Sub
    
        Private Sub Buttono_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttono.Click
            SendKeys.Send("o")
        End Sub
    
        Private Sub Buttonp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonp.Click
            SendKeys.Send("p")
        End Sub
    
        Private Sub Buttonq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonq.Click
            SendKeys.Send("q")
        End Sub
    
        Private Sub Buttonr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonr.Click
            SendKeys.Send("r")
        End Sub
    
        Private Sub Buttons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttons.Click
            SendKeys.Send("s")
        End Sub
    
        Private Sub Buttont_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttont.Click
            SendKeys.Send("t")
        End Sub
    
        Private Sub Buttonu_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonu.Click
            SendKeys.Send("u")
        End Sub
    
        Private Sub Buttonv_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonv.Click
            SendKeys.Send("v")
        End Sub
    
        Private Sub Buttonw_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonw.Click
            SendKeys.Send("w")
        End Sub
    
        Private Sub Buttonx_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonx.Click
            SendKeys.Send("x")
        End Sub
    
        Private Sub Buttony_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttony.Click
            SendKeys.Send("y")
        End Sub
    
        Private Sub Buttonz_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonz.Click
            SendKeys.Send("z")
        End Sub
    End Class
    2009年10月26日 9:14
  • 你好!
         尝试把ExStyle改成0x08000000L样式!
    周雪峰
    2009年10月26日 15:13
    版主
  • 你好!
         尝试把ExStyle改成0x08000000L样式!
    周雪峰

    改后说错误
    2009年10月27日 2:46
  • 类似于这样:
            protected
     override
     CreateParams CreateParams
    {
    get
    {
    CreateParams cp = base .CreateParams;
    cp.ExStyle |= (int )0x08000000L; //把窗体设置成WS_EX_NOACTIVATE样式
     return cp;
    }
    }

    周雪峰
    2009年10月27日 7:53
    版主
  • 类似于这样:
            protected
    
     override
    
     CreateParams CreateParams
    {
    get
    {
    CreateParams cp = base .CreateParams;
    cp.ExStyle |= (int )0x08000000L; //把窗体设置成WS_EX_NOACTIVATE样式
     return cp;
    }
    }

    周雪峰

    怎么还是错误?
    我用的是VS2008,不是C语言!
    2009年10月28日 2:36
  • 这个是C#代码!如果你想要VB.NET代码,可以用工具转换一下!
    周雪峰
    2009年10月28日 4:46
    版主
  • 你好!

    这里提供个免费的代码转换工具: http://www.developerfusion.com/tools/convert/vb-to-csharp/

    希望对你有所帮助。

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    2009年10月28日 4:57
  • 转换后的代码和我程序中的代码是一模一样啊!怎么还是有焦点问题?????我想我的代码应该不会打错到其他地方啊!这个代码是打在软键盘窗体的不是吗?
    2009年10月28日 8:52
  • 请问你具体出现了什么错误?
    周雪峰
    2009年10月28日 9:45
    版主
  • 我说的错误就是运行调试时打开登陆窗体Form1,的软键盘那么焦点就转到Form12“软键盘”身上,当我点击软键盘上面字符输入密码时,焦点就回到登陆窗体!然后软键盘就藏到登陆窗体的后面!
    现在就是这个问题没有解决!
    QQ的软键盘怎么点也不会这样啊!


    2009年10月29日 2:11
  • 你按我上面说的设置了样式了吗?
    我这里测试可以正确的处理输入焦点的问题
    周雪峰
    2009年10月29日 6:35
    版主
  • 没错啊!对啊!!!我有设置啊,这个代码一模一样啊。
    Public Class keyboard
      
        Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
            Get
                Dim Cp As CreateParams = MyBase.CreateParams
                Cp.ExStyle = Cp.ExStyle Or CInt(134217728L)
    
                Return Cp
    
            End Get
        End Property
        Private Sub keyboard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    不是这样吗?
    2009年10月29日 7:29
  • 我不是说把样式改成0x08000000L吗?你并没有改啊!
    周雪峰
    2009年10月29日 11:47
    版主
  • 改了啊!你的C代码中的0x08000000L翻译为VB.net后就成134217728L啊!
    如果把134217728L替换为0x08000000L的话就出现错误!
    2009年10月30日 1:24
  • 怎么办啊??????
    2009年11月2日 2:04