AppActivate 语句
      激活一应用程序窗口。语法AppActivate title[, wait]AppActivate 语句的语法具有以下几个命名参数:部分 描述 
title 必需的。字符串表达式,所要激活的应用程序窗口的标题。可以使用 Shell 函数返回的任务识别码来替换 title,以激活应用程序。 
wait 可选的。Boolean 值,说明在激活另一个应用程序之前调用的应用程序是否有焦点。如果为 False(缺省),那么,即使调用的应用程序没有焦点,也直接激活指定的应用程序。如果为 True,则调用的应用程序会等到有焦点后,才激活指定的应用程序。 
说明AppActivate 语句将焦点移动到命名的应用程序或窗口,但并不影响焦点是否最大化或最小化。当用户采取行动改变焦点或将窗口关闭时,就会将焦点从活动的应用程序窗口移动出去。可用 Shell 函数启动一个应用程序并设置窗口样式。在决定激活哪个应用程序时,请将 title 与每一个运行中的应用程序的标题字符串进行比较。如果没有完全匹配,就激活任何这样的应用程序,其标题字符串以 title 开头。如果以 title 命名的应用程序有很多实例,则激活任何一个实例。

解决方案 »

  1.   


       使用函数:SetWindowPlacement     下面是例子。Private Const SW_MINIMIZE = 6
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Private Type WINDOWPLACEMENT
            Length As Long
            flags As Long
            showCmd As Long
            ptMinPosition As POINTAPI
            ptMaxPosition As POINTAPI
            rcNormalPosition As RECT
    End Type
    Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    Dim Rectan As RECT
    Private Sub Form_Load()
        'Tip submitted by pyp99 ([email protected])
        Dim WinEst As WINDOWPLACEMENT
        Dim rtn As Long
        WinEst.Length = Len(WinEst)
        'get the current window placement
        rtn = GetWindowPlacement(Me.hwnd, WinEst)
        Rectan = WinEst.rcNormalPosition
    End Sub
    Private Sub Command1_Click()
        Dim WinEst As WINDOWPLACEMENT
        Dim Punto As POINTAPI
        Dim rtn As Long
        'set the new min/max positions
        Punto.x = 100
        Punto.y = 100
        'initialize the structure
        WinEst.Length = Len(WinEst)
        WinEst.showCmd = SW_MINIMIZE
        WinEst.ptMinPosition = Punto
        WinEst.ptMaxPosition = Punto
        WinEst.rcNormalPosition = Rectan
        'set the new window placement (minimized)
        rtn = SetWindowPlacement(Me.hwnd, WinEst)
    End Sub