我現(xiàn)在沒有現(xiàn)成的代碼給你,不過可以給你一些建議。如果你想在同一進(jìn)程內(nèi)實(shí)現(xiàn)屏幕鍵盤,則你只需要再F2打開的時候,將F1的當(dāng)前焦點(diǎn)控件對象作為參數(shù),傳遞給F2窗體,在F2點(diǎn)擊屏幕控件時,設(shè)置該“控件.Text
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供云州網(wǎng)站建設(shè)、云州做網(wǎng)站、云州網(wǎng)站設(shè)計、云州網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、云州企業(yè)網(wǎng)站模板建站服務(wù),10年云州做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
=
鍵值”
即可,這種我稱之為假屏幕鍵盤。如果你想跨進(jìn)程實(shí)現(xiàn)屏幕鍵盤,就比較難些了(比如:你想用你的F2窗體上的按鍵,實(shí)現(xiàn)QQ聊天內(nèi)容的輸入、記事本內(nèi)容的輸入)。這個需要用到
“鍵盤鉤子”技術(shù),有關(guān)這方面的資料,你不妨自己找找。
另外,你提的F2焦點(diǎn)老處理不好,我認(rèn)為F2根本不需要焦點(diǎn)控件(不要用按鈕做控件,而實(shí)用Label或圖片就可以了。)
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler Label1.MouseEnter, AddressOf LabelMouseEnter
AddHandler Label2.MouseEnter, AddressOf LabelMouseEnter
AddHandler Label1.MouseLeave, AddressOf LabelMouseLeave
AddHandler Label2.MouseLeave, AddressOf LabelMouseLeave
AddHandler Label1.MouseDown, AddressOf LabelMouseDown
AddHandler Label2.MouseDown, AddressOf LabelMouseDown
End Sub
Private Sub LabelMouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
Dim c As Label = DirectCast(sender, Label)
c.BackColor = Color.DodgerBlue
End Sub
Private Sub LabelMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim c As Label = DirectCast(sender, Label)
Form1.TextBox1.Text = c.Text
End Sub
Private Sub LabelMouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)
Dim c As Label = DirectCast(sender, Label)
c.BackColor = SystemColors.Control
End Sub
End Class
執(zhí)行鍵盤事件方法如下:
第一步,點(diǎn)擊VS工具。
第二步,打開后,新建一個Windows窗體應(yīng)用程序。
第三步,請看右下方Form的屬性欄。
第四步,雙擊KeyDown。
第五步,輸入提示按鍵代碼,如圖所示。
第六步,再次輸入代碼,設(shè)置屬性KeyPreview為true。
第七步,運(yùn)行程序,按下舉例F5,則會彈出提示,表明已經(jīng)成功獲。
樓上的按了一次A+W后,接下來單按W鍵就會彈出信息框
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal keyCode As Integer) As Short
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If GetAsyncKeyState(Keys.A) And GetAsyncKeyState(Keys.W) Then
MsgBox("你按下了A+W鍵")
End If
End Sub
End Class
按照順序的話,這樣寫:
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal keyCode As Integer) As Short
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If GetAsyncKeyState(Keys.A) And e.KeyCode = Keys.W Then
MsgBox("你按下了A+W鍵")
End If
End Sub
End Class
望采納~