网站建设资讯

NEWS

网站建设资讯

vb.net转移焦点 vb tab键 焦点跳转

VB.Net 给其他程序焦点

Public RunProcess As Process

创新互联公司是一家专业提供宝清企业网站建设,专注与网站设计、成都做网站、H5开发、小程序制作等业务。10年已为宝清众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

RunProcess.start("djiwqjidjwqi")

AppActivate(RunProcess.Id())

vb.net设置windows焦点程序

给你个参考的例子,窗体打开时可能大小有变化,软件名可能有变化

先加个控件ListBox1,运行后双击ListBox1上程序名

Public Class Form1

Public myProcess() As Process

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim myProcesses() As Process = Process.GetProcesses()

Dim jh As New ArrayList

For Each bs As Process In myProcesses

If CInt(bs.MainWindowHandle) 0 Then

ListBox1.Items.Add(bs.ProcessName)

jh.Add(bs)

End If

Next

ReDim myProcess(jh.Count - 1)

jh.CopyTo(myProcess)

End Sub

Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Long) As Integer

Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick

Dim a As Process = myProcess(ListBox1.SelectedIndex)

Try

Dim dd = ShowWindow(a.MainWindowHandle, H1)

AppActivate(a.Id)

Catch ex As Exception

End Try

End Sub

End Class

VB.NET中页面初期显示时按下enter键让焦点在五个textbox控件上顺序移动该怎么办?求大神指点,谢谢!

这样不好,应该使用 Table 键,按照 Table 键顺序来切换。因为回车往往用来确定你要按下页面的确定按钮。如果非要使用回车:

Private Sub 文本框按下回车键(sender As Object, e As KeyEventArgs) Handles TextBox3.KeyDown, TextBox2.KeyDown, TextBox1.KeyDown

If e.KeyCode = Keys.Enter Then

Select Case sender.name

Case "TextBox1"

TextBox2.Focus()

Case "TextBox2"

TextBox3.Focus()

Case "TextBox3"

TextBox1.Focus()

End Select

End If

End Sub


当前题目:vb.net转移焦点 vb tab键 焦点跳转
本文来源:http://njwzjz.com/article/dohsoic.html