谢谢,100分求教请尽量写的详细点,谢谢。

解决方案 »

  1.   

    那里还用劳驾API
    Private Sub Timer1_Timer()
    MsgBox Me.ActiveControl.hWnd
    End Sub
      

  2.   

    新建一个VB工程,在工程的窗口上加一个文本框,再加一个Timer控件,把interval属性设为
    5000,引入两个APIPrivate Declare Function GetFocus Lib "user32" () As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    Private Sub Timer1_Timer()
        Dim i As Long
        i = GetFocus   '得到具有焦点的控件的句柄
        
        Call SetWindowText(i, "I Have Focus")  '测试,改变有焦点的控件标题
        
        
    End Subvb6,window2000编译通过