Office中国论坛/Access中国论坛

标题: [求助]如何获取外部程序窗体的名称 [打印本页]

作者: 喳喳林    时间: 2006-5-30 07:31
标题: [求助]如何获取外部程序窗体的名称
我在模块里定义了:

Public Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long

Public Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long

Public Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long


Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_OWNER = 4

在窗体的代码如下:

Sub FindTitle()
'查找桌面上的所有窗口标题
Dim currwnd As Long, length As Long, i As Integer
Dim listitem As String
currwnd = GetWindow(hwnd, GW_HWNDFIRST)

While currwnd <> 0

length = GetWindowTextLength(currwnd)
listitem = Space(length + 1)

length = GetWindowText(currwnd, listitem, length + 1)
If length > 0 Then
MsgBox listitem
End If

currwnd = GetWindow(currwnd, GW_HWNDNEXT)

Wend
End Sub

Private Sub Command0_Click()
FindTitle
End Sub


运行代码后无错误,但只能获取Access 内部窗体的标题.

有没有办法突破Access这个主窗体的限制,去获取外部程序的窗体标题

请各位高手给点宝贵意见.谢谢 谢谢 谢谢大家[attach]18132[/attach]

作者: tmtony    时间: 2006-5-30 08:45
用API,我以前帮灵芝做过一个实例,你看看是否有帮助

http://www.office-cn.net/Soft/Class3/Class1/200202/468.html

它的功能是什么呢,譬如说我在ACCESS中调用了计算器,然后又回到了ACCESS窗体,但过一会儿,我又想把这个计算器又调出来,而且想自动传些数字给它,让它计算,得出结果。。。 这个程序就是完成这个功能的
作者: tmtony    时间: 2006-5-30 08:46
又找了一下,这里应该是这个实例的源代码.
http://www.office-cn.net/Soft/Class3/Class1/200202/469.html
作者: 喳喳林    时间: 2006-5-30 20:47
就是这个啦,谢谢您的宝贵意见,谢谢.
作者: garyshang    时间: 2007-10-7 19:45
好难找啊!不错

作者: goto2008    时间: 2007-10-8 09:24
学习....




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3