请问如何判断窗口是否获得焦点?比如如何在窗体标题栏变灰时,按钮显示“休息一下”?请问这是靠窗体的哪个属性来控制的?

解决方案 »

  1.   

    Form_GotFocus事件窗口获得焦点
    Form_LostFocus事件窗口失去焦点
      

  2.   

    Option ExplicitPrivate Sub Form_GotFocus()
        Command1.Caption = "hello"
    End SubPrivate Sub Form_LostFocus()
        Command1.Caption = "Bye"
    End Sub没反应呀?
      

  3.   

    Private Sub Form_LostFocus()
    Command1.Caption = "休息一下!"
    End Sub
      

  4.   

    Private Sub Form_Activate()
        MsgBox "Activate"
    End SubPrivate Sub Form_Deactivate()
        MsgBox "休息一下!""
    End Sub
      

  5.   

    就像这样,它始终显示“hello”
    Private Sub Form_Activate()
        Command1.Caption = "hello"
    End SubPrivate Sub Form_Deactivate()
        Command1.Caption = "bye"
    End Sub