Option ExplicitPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const WM_SETTEXT = &HC Private Declare Function SetFocusApi Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As LongPrivate Sub Command1_Click() If Text1.Text = "123" Then MsgBox "YES" Else MsgBox "NO" End If End SubPrivate Sub Command2_Click() SendMessage Text1.hwnd, WM_SETTEXT, 0&, ByVal "123" SetFocusApi Command1.hwnd SendKeys "{enter}" End Sub 单击按钮,通常是发送下面两条消息: Private Const WM_LBUTTONUP = &H202 Private Const WM_LBUTTONDOWN = &H201 但是,这两个消息的使用比较麻烦
to daviddivad(你真行,居然比我还快! Scorpio) : 用SendMessage 发送WM_COMMAND消息时,需要用到type nmclick,能提供一下声明吗?
用SetWindowText试试:Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As LongPrivate Sub Command1_Click() SetWindowText Text1.Text, "1234abc" End Sub
to rainstormmaster(rainstormmaster)private type POINT x as long y as long end typeprivate type NMHDR hwndFrom as long idFrom as long code as long end typeprivate type NMCLICK hdr as NMHDR dwItemSpec as long dwItemData as long pt as POINT dwHitInfo as long end type
1,SetWindowText
2,SendMessage 消息为WM_COMMAND
Private Const WM_SETTEXT = &HC
Private Declare Function SetFocusApi Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As LongPrivate Sub Command1_Click()
If Text1.Text = "123" Then
MsgBox "YES"
Else
MsgBox "NO"
End If
End SubPrivate Sub Command2_Click()
SendMessage Text1.hwnd, WM_SETTEXT, 0&, ByVal "123"
SetFocusApi Command1.hwnd
SendKeys "{enter}"
End Sub
单击按钮,通常是发送下面两条消息:
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDOWN = &H201
但是,这两个消息的使用比较麻烦
用SendMessage 发送WM_COMMAND消息时,需要用到type nmclick,能提供一下声明吗?
bwnd = FindWindowEx(twnd, ByVal 0&, "tedit", vbNullString)
Call SendMessage(bwnd, wm_settext, 255, ByVal "12345")
请问大虾:我以上的语句运行后为什么"tedit"框中却没有任何内容,到底错在哪儿?
bwnd = FindWindowEx(twnd, ByVal 0&, "tedit", vbNullString)
Call SendMessage(bwnd, wm_settext, 0, ByVal "12345")请问大虾:我以上的语句运行后为什么"tedit"框中却没有任何内容,到底错在哪儿?
返回值是需要的值吗(用spy查看一下结果)
怎么会事呢?郁闷!
http://www.china-askpro.com/msg33/qa99.shtml
SetWindowText Text1.Text, "1234abc"
End Sub
x as long
y as long
end typeprivate type NMHDR
hwndFrom as long
idFrom as long
code as long
end typeprivate type NMCLICK
hdr as NMHDR
dwItemSpec as long
dwItemData as long
pt as POINT
dwHitInfo as long
end type
我在xp下用的,没问题呀。
不是Text1.hwnd,而是在其他应用程序中的文本框