189 8069 5689

vb.net焦点切换 vb设置焦点

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 给其他程序焦点

Public RunProcess As Process

RunProcess.start("djiwqjidjwqi")

AppActivate(RunProcess.Id())


标题名称:vb.net焦点切换 vb设置焦点
转载源于:http://jkwzsj.com/article/dosdeic.html

其他资讯