1。怎样或许当前鼠标所点击的按钮的句柄、名称、标题呢?
2。怎样使前一步的按钮产生一个点击事件呢

解决方案 »

  1.   

    1
    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
      

  2.   

    2.BM_CLICK
    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.
      

  3.   

    首先,你要得到一个按钮的句柄有很多方法,我这里告诉你一个简单的方法!
    你新建一个工程,然后在空窗体上随便扔几个按钮。
    然后放一个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
      

  4.   

    Shikari(很久不来) 这你放心,分我一定照给你就帮忙帮到底,:),谢谢!