1。怎样或许当前鼠标所点击的按钮的句柄、名称、标题呢?
2。怎样使前一步的按钮产生一个点击事件呢
2。怎样使前一步的按钮产生一个点击事件呢
解决方案 »
- vb调用vc动态连接库问题!!(100分求)
- 用MSXML.XMLHTTPRequest取得ASP网页返回的html代码,如何把这些内容显示成正常的网页文本?
- 哪有vb6.0下载
- 关于VB+access创建超市管理系统的问题
- 关于日期类型的问题!在线等待!
- 提个有点难度的问题。。。
- 在win7旗舰版中smartmenuxp控件的问题
- 我在Form上print了一条曲线,可是当其它窗体将它覆盖后,那条曲线就被抹点了,这该怎麽办啊
- 编程设置共享文件夹,是不是用API函数?在线等待!!
- 请教有关web page拼接问题??
- 请问:发送邮件除了MAPI之外,还有其他更好的方法吗?不用outlook
- 人又老,钱又无,女朋友又跟人走路
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Sub Form_Paint()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Draw the current cursor on this form
DrawIcon Me.hdc, 0, 0, GetCursor
End Sub
An application sends a BM_CLICK message to simulate the user clicking a button. This message causes the button to receive a WM_LBUTTONDOWN and a WM_LBUTTONUP message, and the button's parent window to receive a BN_CLICKED notification message.BM_CLICK
wParam = 0; // not used; must be zero
lParam = 0; // not used; must be zero
Parameters
This message has no parameters. Return Values
This message does not return a value.Res
If the button is in a dialog box and the dialog box is not active, the BM_CLICK message might fail. To ensure success in this situation, call the SetActiveWindow function to activate the dialog box before sending the BM_CLICK message to the button.QuickInfo
Windows NT: Requires version 3.5 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
你新建一个工程,然后在空窗体上随便扔几个按钮。
然后放一个TIMER,INTERVAL=100
然后再放两个TEXTBOX下面是代码
首先声明
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Sub Timer1_Timer()
Dim MyPoint As POINTAPI
GetCursorPos MyPoint
Dim MyHwnd As Long
MyHwnd = WindowFromPoint(MyPoint.x, MyPoint.y)
If MyHwnd <> 0 Then
Dim MyClassName As String * 255
Dim MyWindowTitle As String * 255
GetClassName MyHwnd, MyClassName, 255
GetWindowText MyHwnd, MyWindowTitle, 255
Text1.Text = MyClassName
Text2.Text = MyWindowTitle
End If上面的代码是当你鼠标移动到任意一个窗体或按钮时,TEXTBOX中会显示该窗口的类名和名称!
如果你想给某个按钮发点击事件,就可以这么写
SendMessage Hwnd,&HF5,0,0