VB窗体控制示例


'以下添加到窗体中
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

'以下为按钮事件中
Private Sub Command1_Click()
    Dim lhWnd As Long'Holds the handle To the window

   '获取到的窗体名称
    lhWnd = FindWindow("Minesweeper", "Minesweeper")
    Text1.Text = lhWnd

    If lhWnd <> 0 Then
       '闪烁窗体
        FlashWindow lhWnd, 1
    End If

    If lhWnd <> 0 Then
        '改变窗体标题
        SetWindowText lhWnd, "我改变了你的窗体的标题啦"
    End If
End Sub
 

你可能感兴趣的:(vb)