vb.net查所有子窗口 vb窗口文件

vb.net 获取子窗口的变量值

用CType转成你的窗口类型就可以引用了

创新互联建站主要从事成都做网站、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务凭祥,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

比如你的子窗口类是MyForm

单击父窗口Button2显示它包含字符串MyPath的内容的代码如下

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

MsgBox(CType(Me.ActiveMdiChild, MyForm).MyPath)

End Sub

vb.net如何查找打开的窗口

将NewForm设置为全局变量就可以了,如果新建窗口比较多,就设置为数组,例如:

Public Class Form1

Dim NewForm(10) As Form

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

NewForm(0) = New Form

NewForm(0).Show()

End Sub

End Class

VB怎么寻找子窗口

根据补充信息,修改如下:

在窗体上加入控件command1,然后复制下面代码,运行,启动画图程序,单击command1,即可找到你要的画纸的句柄!

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub Command1_Click()

Dim huatu, huazi

Dim i As Integer

huatu = FindWindowEx(0, 0, vbNullString, "未命名 - 画图")

Do Until huatu = 0

huazi = FindWindowEx(huatu, 0, "AfxFrameOrView42u", vbNullString)

huazi = FindWindowEx(huazi, 0, "Afx:1000000:8", vbNullString)

i = i + 1

MsgBox "找到第" i "个画纸,它的句柄是:" huazi

huatu = FindWindowEx(0, huatu, vbNullString, "未命名 - 画图")

Loop

End Sub


当前文章:vb.net查所有子窗口 vb窗口文件
网站路径:http://cdiso.cn/article/hpjgpi.html

其他资讯