0

次のコードは、必要な IE ウィンドウにフォーカスを設定せず、本来のように最大化もしません。

Option Explicit On
Public Class Form1
    Public Declare Auto Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Sub automateIE()
        Dim shellWindows = New SHDocVw.ShellWindowsClass()
        For Each ie As SHDocVw.InternetExplorer In shellWindows
            Dim isIE As Boolean = True
            Try
                Dim ie2 As mshtml.IHTMLDocument = ie.Document
            Catch ex As Exception
                isIE = False
            End Try
            If isIE Then
                If ie.LocationURL.Contains("url") Then
                    ShowWindow(ie.HWND, 3)
                    Exit For
                End If
            End If
        Next
    End Sub
End Class
4

1 に答える 1

1

変更(VB6)

Public Declare Auto Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

宛先(VB.NET)

Imports System.Runtime.InteropServices
...
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As ShowWindowCommands) As Boolean
End Function
Enum ShowWindowCommands As Integer
    SW_MAXIMIZE = 3
    ...
End Enum

ハンス・パッサンのコメントに感謝します

于 2011-09-14T12:52:11.450 に答える