| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4114 人关注过本帖
标题:新手请教sendmessage的用法
取消只看楼主 加入收藏
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
redice 有时间教一下我 好吗?

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-19 23:23
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
  师傅。。。。。。非常感谢

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 14:19
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
师傅~
Private Const WM_KEYDOWN = &H100 "这个定义什么的呢?
Private Sub Command1_Click()
Dim findhwnd As Long
findhwnd = FindWindow(vbNullString, "消息接收窗体") "为什么运行程序的时候,这个代码会提示类型不匹配呀?“消息接收窗体”是窗体句柄么?
If findhwnd = vbNullString Then "这段又是什么意思呀?
MsgBox "接受消息窗体没有运行", 0, "报告"
Exit Sub
End If
SendMessage findhwnd, WM_KEYDOWN, 65, 1& "这段呢?
End Sub
师傅,你的代码没有注释。我不是很理解,无从改起。

[此贴子已经被作者于2007-4-20 14:58:05编辑过]


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 14:46
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
回复:(b13690976754)新手请教sendmessage的用法
经过研究我已经掌握了 怎么获得窗口的句柄(师傅功劳最大)但是我向窗体发送信息时 遇到这个错误。。
图片附件: 游客没有浏览图片的权限,请 登录注册


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 17:09
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)

Private Const WM_KEYDOWN = &H100
Private Sub Command1_Click()
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
Dim hwnd As Long '
hwnd = FindWindow(vbNullString, "Crazy Arcade")
If hwnd = 0 Then
Label1.Caption = "未运行"
Else
Label1.Caption = "已运行"
SendMessage findhwnd, WM_KEYDOWN, 65, 1& 这个出错了。如果我要向 泡泡堂 发送一个字符怎么改? (比如我发送 : 你好 )怎么样才能不出现DLL错误?
End If
End Sub


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 17:54
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
以下是引用redice在2007-4-20 17:58:30的发言:
真不好意思 我写错了一点
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) as long

SendMessage findhwnd, WM_KEYDOWN, 65, 0 & (你又少写了个)

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long

Private Sub Command1_Click()
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
Dim hwnd As Long '
hwnd = FindWindow(vbNullString, "Crazy Arcade")
If hwnd = 0 Then
Label1.Caption = "未运行"
Else
Label1.Caption = "已运行"
SendMessage findhwnd, wm_keydown, 65, 0& (虽然不会出现DLL错误,但不会输入A。。????)
End If
End Sub


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 18:04
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
师傅不在吗?

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 18:30
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 

师傅这个是改你编的程序,发现一个问题,这个程序只对你编的另一个窗体有效果,对其他任何一个活动窗体不起作用。。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long

Private Const WM_KEYDOWN = &H100
Private Sub Command1_Click()
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
Dim hwnd As Long '
hwnd = FindWindow(vbNullString, "Crazy Arcade")
If hwnd = 0 Then
Label1.Caption = "未运行"
Else
Label1.Caption = "已运行"
SendMessage findhwnd, wm_keydown, 65, 0&
End If
End Sub

[此贴子已经被作者于2007-4-20 18:55:26编辑过]


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 18:53
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 

Private Const WM_KEYDOWN = &H100好象用的不对吧?
不然怎么不可以呢???


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 18:56
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
收藏
得分:0 
师傅有事忙,我等!

If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 19:08
快速回复:新手请教sendmessage的用法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019589 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved