想在一个VB程序中,引用另一个VB程序的msgbox中显示的结果

tulonghou 2009-05-13 01:08:35
我有一个问题,请高手回答一下:
想在一个VB程序中,引用另一个VB程序的msgbox中显示的结果,该怎么做,拜托了。
...全文
201 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
starxiang 2009-07-30
  • 打赏
  • 举报
回复
谢谢LZ了,正在找这个
futosky 2009-07-29
  • 打赏
  • 举报
回复
见到API就收
孤独剑_LPZ 2009-05-14
  • 打赏
  • 举报
回复
5楼的,好样的,测试通过了,楼主赶紧给人家加分吧
我是一道光_ 2009-05-14
  • 打赏
  • 举报
回复
不错,5楼的实现了,收藏了
zhuhuofong 2009-05-14
  • 打赏
  • 举报
回复
up
舉杯邀明月 2009-05-13
  • 打赏
  • 举报
回复
楼主,试一下这段代码:
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 hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

Private Sub Command1_Click()

Dim hWndMSG&, lTemp&, i&, strOut$

'你在用的时候,把这‘记事本’换成你实际的消息框标题.
hWndMSG = FindWindow("#32770", "记事本")
If (hWndMSG = 0) Then MsgBox "没有找到消息框!", 48, "查找窗口": Exit Sub
lTemp = 0
Do
lTemp = FindWindowEx(hWndMSG, lTemp, vbNullString, vbNullString)
If (lTemp > 0) Then If ((GetWindowLong(lTemp, -16&) And 128&) = 128&) Then Exit Do
Loop While (lTemp > 0)
If (lTemp = 0) Then MsgBox "没有找到消息内容窗口!", 48, "查找窗口": Exit Sub
i = GetWindowTextLength(lTemp) + 1
strOut = String(i, vbNullChar)
GetWindowText lTemp, strOut, i
MsgBox strOut, 64, "找到的消息内容"

End Sub

SYSSZ 2009-05-13
  • 打赏
  • 举报
回复
不容易唉!很难的,胡说不行.
jhone99 2009-05-13
  • 打赏
  • 举报
回复
呵呵,有一个笨法

把另一个程序的msgbox内容存到text里,这个程序再读取
tulonghou 2009-05-13
  • 打赏
  • 举报
回复
我是新手,能给段代码吗?谢谢了
舉杯邀明月 2009-05-13
  • 打赏
  • 举报
回复
可能需要用到下列 API:
FindWindow()
FindWindowEx()
GetWindowTextLength()
GetWindowText()

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧