从品牌网站建设到网络营销策划,从策略到执行的一站式服务
用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
将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
根据补充信息,修改如下:
在窗体上加入控件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
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图